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.
Any chance you could upload a sample file that shows the problem, along with a short junit unit test which triggers the exception with it?
Created attachment 31757 [details] A blank workbook created in Excel 2013 This is one of the workbooks I've used to test the issue. Unfortunately, I have no skill with JUnit.
Should be fixed in trunk via bug 57482, checked in with r1653825. *** This bug has been marked as a duplicate of bug 57482 ***