https://bz.apache.org/bugzilla/show_bug.cgi?id=60010
Bug ID: 60010
Summary: SXSSFWorkbook.write() fails when the template is based
on PackageAccess.READ OPCPackage
Product: POI
Version: 3.14-FINAL
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P2
Component: SXSSF
Assignee: [email protected]
Reporter: [email protected]
Observed behavior:
When a SXSSFWorkbook workbook is created from a template which is "read-only"
(initiated with PackageAccess.READ mode OPCPackage), then writing that workbook
to another file is failing.
Expected behavior:
Since the SXSSFWorkbook is written to another file - it should be possible to
save it even when the template has been open in read only mode.
Stack trace:
Exception in thread "main"
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:520)
at
org.apache.poi.openxml4j.opc.OPCPackage.removePart(OPCPackage.java:943)
at
org.apache.poi.openxml4j.opc.PackagePart.getOutputStream(PackagePart.java:522)
at
org.apache.poi.xssf.usermodel.XSSFWorkbook.commit(XSSFWorkbook.java:1687)
at
org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:464)
at org.apache.poi.POIXMLDocument.write(POIXMLDocument.java:211)
at
org.apache.poi.xssf.streaming.SXSSFWorkbook.write(SXSSFWorkbook.java:939)
at jvdemos.poi.PoiDemo.testPoi(PoiDemo.java:31)
at jvdemos.poi.PoiDemo.main(PoiDemo.java:47)
Code:
20 OPCPackage pkg = OPCPackage.open(templateFilename,
PackageAccess.READ);
21 XSSFWorkbook template = new XSSFWorkbook(pkg);
22 // pkg.revert();
23 // pkg.close();
24 // in.close();
25
26 SXSSFWorkbook workbook = new SXSSFWorkbook(template, 100);
28 fillData(workbook);
30 FileOutputStream out = new FileOutputStream("/tmp/out1.xlsx");
31 workbook.write(out);
32 out.close();
--
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]