https://issues.apache.org/bugzilla/show_bug.cgi?id=56675
Bug ID: 56675
Summary: Cannot create new XSSFWorkbook from an OPCPackage that
opened an Excel 2013 file with PackageAccess.READ
Product: POI
Version: 3.10
Hardware: PC
Status: NEW
Severity: normal
Priority: P2
Component: XSSF
Assignee: [email protected]
Reporter: [email protected]
I've attempted to open files created in Excel 2013 as an XSSFWorkbook via an
OPCPackage with PackageAccess.READ, but it throws a POIXMLException with the
following stack (I have added my code after):
Exception in thread "main" org.apache.poi.POIXMLException:
org.apache.poi.openxml4j.exceptions.InvalidOperationException: Operation not
allowed, document open in read only mode!
at
org.apache.poi.POIXMLDocumentPart.createRelationship(POIXMLDocumentPart.java:393)
at
org.apache.poi.POIXMLDocumentPart.createRelationship(POIXMLDocumentPart.java:353)
at
org.apache.poi.xssf.usermodel.XSSFWorkbook.onDocumentRead(XSSFWorkbook.java:288)
at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:159)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:200)
at workbook.io.WorkbookReaderTest.<init>(WorkbookReaderTest.java:19)
at workbook.io.WorkbookReaderTest.main(WorkbookReaderTest.java:25)
Caused by: org.apache.poi.openxml4j.exceptions.InvalidOperationException:
Operation not allowed, document open in read only mode!
at
org.apache.poi.openxml4j.opc.OPCPackage.throwExceptionIfReadOnly(OPCPackage.java:507)
at org.apache.poi.openxml4j.opc.OPCPackage.createPart(OPCPackage.java:765)
at org.apache.poi.openxml4j.opc.OPCPackage.createPart(OPCPackage.java:741)
at
org.apache.poi.POIXMLDocumentPart.createRelationship(POIXMLDocumentPart.java:373)
... 6 more
Here's my code:
public final class WorkbookReaderTest {
public WorkbookReaderTest(File inputFile) throws InvalidFormatException,
IOException {
OPCPackage pkg = OPCPackage.open(inputFile, PackageAccess.READ);
XSSFWorkbook wb = new XSSFWorkbook(pkg);
}
public static void main(String[] args) throws InvalidFormatException,
IOException {
new WorkbookReaderTest(new File("C:\\path\\blank workbook.xlsx"));
}
}
It seems that XLSX files created in Excel 2013 are the problem. XLSX files
created in 2010 and then modified in 2013 seem to pose no problem, provided
that at least 2 sheets remain from the original; when cut down to only 1 sheet
from the original, I get the same exception, even if the 1 original sheet has
new accompanying sheets in the same workbook.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]