[Bug 60010] New: SXSSFWorkbook.write() fails when the template is based on PackageAccess.READ OPCPackage

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug 60010] New: SXSSFWorkbook.write() fails when the template is based on PackageAccess.READ OPCPackage

Bugzilla from bugzilla@apache.org
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: [hidden email]
          Reporter: [hidden email]

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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 60010] SXSSFWorkbook.write() fails when the template is based on PackageAccess.READ OPCPackage

Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=60010

Nick Burch <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #1 from Nick Burch <[hidden email]> ---
Can you try with a recent nightly build / build from svn / build from git /
wait a few more days and try with POI 3.15 beta 3 when out? Only we've fixed
some bugs around this sort of thing since 3.14 final, so it may already be
solved

--
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 60010] SXSSFWorkbook.write() fails when the template is based on PackageAccess.READ OPCPackage

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=60010

Yavor <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW

--- Comment #2 from Yavor <[hidden email]> ---
I just tried with the nightly build poi-bin-3.15-beta4-20160815.tar.gz - it
fails too:
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:585)
    at org.apache.poi.openxml4j.opc.OPCPackage.removePart(OPCPackage.java:1008)
    at
org.apache.poi.openxml4j.opc.PackagePart.getOutputStream(PackagePart.java:521)
    at
org.apache.poi.xssf.usermodel.XSSFWorkbook.commit(XSSFWorkbook.java:1765)
    at org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:486)
    at org.apache.poi.POIXMLDocument.write(POIXMLDocument.java:236)
    at
org.apache.poi.xssf.streaming.SXSSFWorkbook.write(SXSSFWorkbook.java:941)

--
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 60010] SXSSFWorkbook.write() fails when the template is based on PackageAccess.READ OPCPackage

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=60010

--- Comment #3 from Nick Burch <[hidden email]> ---
Disabled unit test added to TestSXSSFWorkbook in r1760458. Because of the way
that SXSSF sits on top of XSSF, it might not be a very quick fix. However, with
any luck the changes needed for finishing in-place write support may solve this
case too

--
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 60010] SXSSFWorkbook.write() fails when the template is based on PackageAccess.READ OPCPackage

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=60010

Sz.Noemi <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[hidden email]

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]