https://issues.apache.org/bugzilla/show_bug.cgi?id=57482
Bug ID: 57482
Summary: InvalidOperationException occurs when creating
XSSFWorkbook with PackageAccess.READ
Product: POI
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P2
Component: XSSF
Assignee: [email protected]
Reporter: [email protected]
Created attachment 32390
--> https://issues.apache.org/bugzilla/attachment.cgi?id=32390&action=edit
Numeric value only Excel (xlsx) and Unit test
I got the following stack trace when creaing XSSFWorkbook with
PackageAccess.READ:
Unstructured_Data_0,0: 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:370)
at
org.apache.poi.POIXMLDocumentPart.createRelationship(POIXMLDocumentPart.java:330)
at
org.apache.poi.xssf.usermodel.XSSFWorkbook.onDocumentRead(XSSFWorkbook.java:274)
at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:159)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:186)
...
My code is like below.
XSSFWorkbook workbook = new
XSSFWorkbook(OPCPackage.open(file.getAbsolutePath(), PackageAccess.READ));
It usually works fine; however the above exception occurs when reading some
Excel (xlsx) files. I found similar bug reports such as 55948 and 56675, but
unfortunately they are not fixed yet.
As a result of my investigation, I recognized this issue occurs when reading an
xlsx file that contains only numeric data. In this case there is no shared
string table, POI tries to create a new part named "/xl/sharedStrings.xml" and
then throws the exception.
It seems a POI logic issue. It should be allowed even if PackageAccess.READ is
specified.
--
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]