You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2015/01/22 09:31:25 UTC

[Bug 57482] New: InvalidOperationException occurs when creating XSSFWorkbook with PackageAccess.READ

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: dev@poi.apache.org
          Reporter: isaokk3@gmail.com

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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 57482] InvalidOperationException occurs when creating XSSFWorkbook with PackageAccess.READ

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=57482

--- Comment #1 from Nick Burch <ap...@gagravarr.org> ---
Thanks for this

I've slightly re-worked your unit test, and added it in r1653814.

Now to fix it...

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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 57482] InvalidOperationException occurs when creating XSSFWorkbook with PackageAccess.READ

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=57482

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |skia.heliou@gmail.com

--- Comment #3 from Dominik Stadler <do...@gmx.at> ---
*** Bug 56675 has been marked as a duplicate of this bug. ***

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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 57482] InvalidOperationException occurs when creating XSSFWorkbook with PackageAccess.READ

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=57482

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |david@carr.name

--- Comment #4 from Dominik Stadler <do...@gmx.at> ---
*** Bug 55948 has been marked as a duplicate of this bug. ***

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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 57482] InvalidOperationException occurs when creating XSSFWorkbook with PackageAccess.READ

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=57482

Nick Burch <ap...@gagravarr.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #2 from Nick Burch <ap...@gagravarr.org> ---
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!

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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org