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 2011/06/28 11:51:50 UTC

DO NOT REPLY [Bug 51444] New: Writing XSSF to stream produces unreadable content when XSSF is read from stream

https://issues.apache.org/bugzilla/show_bug.cgi?id=51444

             Bug #: 51444
           Summary: Writing XSSF to stream produces unreadable content
                    when XSSF is read from stream
           Product: POI
           Version: 3.7
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
        AssignedTo: dev@poi.apache.org
        ReportedBy: milan.chudik@mapflow.com
    Classification: Unclassified


Created attachment 27221
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=27221
Junit test file, workbook.xls,workbook.xlsx

hi,

I just experience strange fact that is similar to bug 51158, but not really the
same.

When I create workbook "by hand" via new operator, I can store XSSFWorkbook to
a file(outputstream), that works ok(I don't need to store it twice-though it
yields error too)
But when I read a workbook from a stream, let's say file, and store it to
another file, virtually creating a copy, then the result file is unreadable.

Use case is, that I want to report only one sheet(current) I'm working on, then
I create a XSSFWorkbook from InputStream, remove unnecessary sheets and then
store it via write method to a new OutStream and passes that stream further for
processing. BUT this stream is unreadable, if I want to read from this stream I
get this exception:

ava.lang.NullPointerException
        at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:256)
        at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:186)
        at
org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:182)
        at
org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:63)

If I write it to a file, file is unreadable.
I debugged it it I find out, that writing fails on "Dublicate entry:
docProps/core.xml" in I think DefaultMarshaller(exception is caught in
org.apache.poi.openxml4j.opc.ZipPackage.saveImpl)

I attach test file that demonstrates issues and example excel files.

I experience this error both in 3.7 and 3.8-beta3
Regards,

Milan

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- 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


DO NOT REPLY [Bug 51444] Writing XSSF to stream produces unreadable content when XSSF is read from stream

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

--- Comment #2 from milan <mi...@mapflow.com> 2011-06-28 14:14:38 UTC ---
both files are created in libraoffice(former openoffice)

yes I just saved it again as OpenXML file.

Hmm, maybe there is a problem with OpenOffice implementation?

Still how can I ensure I will not receive such a file from a third party?
(we try to process XLS and XLSX files sent from external sources, so we have no
control over these files, how they are populated, etc)
And that file can be reopened in OpenOffice as a valid file. So it looks good.

I wrote a workaround that copies XSSFworkbook, sheet by sheet, cell by cell, so
I can manage so far, but it would be nice to have same solution both for XSL
and XLSX files

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- 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


DO NOT REPLY [Bug 51444] Writing XSSF to stream produces unreadable content when XSSF is read from stream

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

--- Comment #6 from milan <mi...@mapflow.com> 2011-06-30 16:25:26 UTC ---
so when do you think this fix will be available in any official release(besides
from checkout from repository)? 
maybe in 3.8-beta4?

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- 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


DO NOT REPLY [Bug 51444] Writing XSSF to stream produces unreadable content when XSSF is read from stream

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

--- Comment #3 from Yegor Kozlov <ye...@dinom.ru> 2011-06-28 15:22:44 UTC ---

(In reply to comment #2)
> both files are created in libraoffice(former openoffice)
> 
> yes I just saved it again as OpenXML file.
> 
> Hmm, maybe there is a problem with OpenOffice implementation?
> 
> Still how can I ensure I will not receive such a file from a third party?
> (we try to process XLS and XLSX files sent from external sources, so we have no
> control over these files, how they are populated, etc)
> And that file can be reopened in OpenOffice as a valid file. So it looks good.
> 
> I wrote a workaround that copies XSSFworkbook, sheet by sheet, cell by cell, so
> I can manage so far, but it would be nice to have same solution both for XSL
> and XLSX files

It looks like POI has a problem re-saving files from LibreOffice.

I suspect that the following differences in [Content_Types].xml cause it:

LibreOffice:
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
  <Override PartName="/_rels/.rels"
ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
  <Override PartName="/docProps/core.xml"
ContentType="application/vnd.openxmlformats-package.core-properties+xml"/>


POI:
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
  <Default Extension="rels"
ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
  <Default Extension="xml" ContentType="application/xml"/>

It might be that LibreOffice is correct and POI does not handle a specific
OOXML case. 

I'm going to install LO and research it.

Yegor

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- 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


DO NOT REPLY [Bug 51444] Writing XSSF to stream produces unreadable content when XSSF is read from stream

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

--- Comment #1 from Yegor Kozlov <ye...@dinom.ru> 2011-06-28 13:36:36 UTC ---
The problem occurs only with attached workbook.xlsx. If I create this file with
the testCreateXLSXFile() method and pass the result to
testReadXLSXFileByeArray() then the test succeeds. 

How did you create workbook.xlsx ? Did you re-save it in Excel after creation? 

Yegor

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- 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


DO NOT REPLY [Bug 51444] Writing XSSF to stream produces unreadable content when XSSF is read from stream

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

--- Comment #4 from milan <mi...@mapflow.com> 2011-06-28 16:19:07 UTC ---
thanks, appreciate

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- 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


DO NOT REPLY [Bug 51444] Writing XSSF to stream produces unreadable content when XSSF is read from stream

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

Yegor Kozlov <ye...@dinom.ru> changed:

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

--- Comment #5 from Yegor Kozlov <ye...@dinom.ru> 2011-06-30 15:40:55 UTC ---
Fixed in r1141576, junit added

Yegor

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- 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