Bug 53819 - Can't read xlsx files with error
Summary: Can't read xlsx files with error
Status: RESOLVED INVALID
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.8-FINAL
Hardware: PC All
: P2 normal with 4 votes (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-03 11:17 UTC by Anton.Cherepanov
Modified: 2012-09-04 13:48 UTC (History)
0 users



Attachments
Test file (252.29 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2012-09-03 11:17 UTC, Anton.Cherepanov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Anton.Cherepanov 2012-09-03 11:17:34 UTC
Created attachment 29319 [details]
Test file

FileInputStream is = new FileInputStream(fileName);
            m_book = WorkbookFactory.create(is);

The simple programe code fales with error:


org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException
	at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:62)
	at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:403)
	at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:408)
	at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:155)
	at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:183)
	at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:73)
	at ru.otr.core.Document.<init>(Document.java:21)
	at ru.otr.EnergyLoader.main(EnergyLoader.java:175)
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.lang.reflect.Constructor.newInstance(Unknown Source)
	at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:60)
	... 7 more
Caused by: org.apache.xmlbeans.XmlException: error: duplicate attribute 'o:relid'
	at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java:3511)
	at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1277)
	at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1264)
	at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:345)
	at org.apache.xmlbeans.XmlObject$Factory.parse(XmlObject.java:688)
	at org.apache.poi.xssf.usermodel.XSSFVMLDrawing.read(XSSFVMLDrawing.java:107)
	at org.apache.poi.xssf.usermodel.XSSFVMLDrawing.<init>(XSSFVMLDrawing.java:102)
	... 12 more
Caused by: org.xml.sax.SAXParseException: duplicate attribute 'o:relid'
	at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.reportFatalError(Piccolo.java:1038)
	at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.parse(Piccolo.java:723)
	at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java:3479)
	... 18 more
Comment 1 Yegor Kozlov 2012-09-03 12:12:49 UTC
The stack trace tells that the file contains invalid xml. I checked the attached file and it is indeed so: 
/xl/drawings/vmlDrawing1.vml contains duplicate attributes which is not allowed,
have a look at the following fragemnt:

  <v:fill o:relid="rId1" o:relid="rId1" o:relid="rId1" o:relid="rId1" o:relid="rId1"
   o:relid="rId1" o:relid="rId1" o:relid="rId1" o:relid="rId1" o:relid="rId1"
   o:relid="rId1" o:relid="rId1" o:relid="rId1" o:relid="rId1" o:relid="rId1"
   o:relid="rId1" o:relid="rId1" o:relid="rId1" o:relid="rId1" o:relid="rId1"
   o:relid="rId1" o:relid="rId1" o:relid="rId1" o:relid="rId1" o:relid="rId1"


I don't see a problem with POI here. What is the origin of this file? Make sure that this application writes correct XML. 

Yegor
Comment 2 Anton.Cherepanov 2012-09-03 13:59:45 UTC
Hi. Yegor.

Thank you for your comment.
This file in attachment is originally created with Microsoft Excel (Ver: 14.0.6123.5001 32-bit)

Anton.



(In reply to comment #1)
> The stack trace tells that the file contains invalid xml. I checked the
> attached file and it is indeed so: 
> /xl/drawings/vmlDrawing1.vml contains duplicate attributes which is not
> allowed,
> have a look at the following fragemnt:
> 
>   <v:fill o:relid="rId1" o:relid="rId1" o:relid="rId1" o:relid="rId1"
> o:relid="rId1"
>    o:relid="rId1" o:relid="rId1" o:relid="rId1" o:relid="rId1" o:relid="rId1"
>    o:relid="rId1" o:relid="rId1" o:relid="rId1" o:relid="rId1" o:relid="rId1"
>    o:relid="rId1" o:relid="rId1" o:relid="rId1" o:relid="rId1" o:relid="rId1"
>    o:relid="rId1" o:relid="rId1" o:relid="rId1" o:relid="rId1" o:relid="rId1"
> 
> 
> I don't see a problem with POI here. What is the origin of this file? Make
> sure that this application writes correct XML. 
> 
> Yegor
Comment 3 Yegor Kozlov 2012-09-04 13:48:33 UTC
POI follows the OOXML spec which requires all package parts to be well-formed XML. If a part is malformed then it is a bug (or a weird feature) of MS Office. 

POI works with XML via XmlBeans and its Piccolo parser does not allow duplicate attributes.

I appears that it is a general behavior:
 - Xerces (the standard XML parser from JDK) cannot parse it either
 - Chrome browser can't parse it
 -  msxml.dll (Windows-wide XML parser) cannot parse it. 

So I don't see a problem with POI here. 

Yegor

(In reply to comment #2)
> Hi. Yegor.
> 
> Thank you for your comment.
> This file in attachment is originally created with Microsoft Excel (Ver:
> 14.0.6123.5001 32-bit)
> 
> Anton.
> 
> 
> 
> (In reply to comment #1)
> > The stack trace tells that the file contains invalid xml. I checked the
> > attached file and it is indeed so: 
> > /xl/drawings/vmlDrawing1.vml contains duplicate attributes which is not
> > allowed,
> > have a look at the following fragemnt:
> > 
> >   <v:fill o:relid="rId1" o:relid="rId1" o:relid="rId1" o:relid="rId1"
> > o:relid="rId1"
> >    o:relid="rId1" o:relid="rId1" o:relid="rId1" o:relid="rId1" o:relid="rId1"
> >    o:relid="rId1" o:relid="rId1" o:relid="rId1" o:relid="rId1" o:relid="rId1"
> >    o:relid="rId1" o:relid="rId1" o:relid="rId1" o:relid="rId1" o:relid="rId1"
> >    o:relid="rId1" o:relid="rId1" o:relid="rId1" o:relid="rId1" o:relid="rId1"
> > 
> > 
> > I don't see a problem with POI here. What is the origin of this file? Make
> > sure that this application writes correct XML. 
> > 
> > Yegor