Given following shared string table, <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"/> XSSF won't work. It seems that we assumed that there would be 'count' and 'uniqCount' in the xml. However if there is no 'count' and 'uniqCount', the excel file cannot be handled successfully. File attached.
You forgot to attach the file. Yegor
The file is about 5MB in size, I failed to upload it. Any other way to share it with you?
Please got the link by following link. http://dl.dropbox.com/u/29681633/cant_upload.xlsx
How was this file generated?
We are building product based on POI. Our user is trying to using the attached file, but failed. The source is unknown. Do you think it's an issue?
(In reply to comment #0) > Given following shared string table, > > <?xml version="1.0" encoding="UTF-8" standalone="yes"?> > <sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"/> > > XSSF won't work. > Please explain what is wrong with XSSF: does it throw an exception or returns wrong data or what? The latest build from trunk can read the referenced file, navigate over data and save it back to file. I don't see anything wrong on the POI side. Yegor
An exception was thrown with following code. import java.io.IOException; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.openxml4j.opc.PackageAccess; import org.apache.poi.xssf.eventusermodel.ReadOnlySharedStringsTable; import org.xml.sax.SAXException; public class Test { public static void main(String[] args) { try { OPCPackage pkg = OPCPackage.open("cant_upload.xlsx", PackageAccess.READ); ReadOnlySharedStringsTable table = new ReadOnlySharedStringsTable(pkg); } catch (InvalidFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SAXException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
Callstack looks like this, at java.lang.Integer.parseInt(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at org.apache.poi.xssf.eventusermodel.ReadOnlySharedStringsTable.startElement(ReadOnlySharedStringsTable.java:190) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source) at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$ContentDriver.scanRootElementHook(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) at org.apache.poi.xssf.eventusermodel.ReadOnlySharedStringsTable.readFrom(ReadOnlySharedStringsTable.java:141) at org.apache.poi.xssf.eventusermodel.ReadOnlySharedStringsTable.<init>(ReadOnlySharedStringsTable.java:110)
I relaxed this constraint in r1299338. With this fix POI's eventusermodel supports parsing SST with missing Count and UniqueCount attributes. Please try the latest build from trunk. Yegor