Created attachment 32390 [details] 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.
Thanks for this I've slightly re-worked your unit test, and added it in r1653814. Now to fix it...
Should be fixed as of r1653825 - in read only mode we now create an empty unbound shared strings table or styles table to get through the reading calls which might use them (Unbound is fine, as writing out isn't supported from a read-only package) Thanks for your help!
*** Bug 56675 has been marked as a duplicate of this bug. ***
*** Bug 55948 has been marked as a duplicate of this bug. ***