Created attachment 23884 [details] xlsx file generated by POI that cannot be opened by OpenOffice After creating an xlsx file with the following sample code, and opening it with OpenOffice 3.x, first it prompts me for the file type, then I choose Microsoft Office 2007 XML, then I get a "General Error. General input/output error". If you open the xlsx file with Excel 2007, then save it, it is then openable by OpenOffice. Also, OpenOffice automatically detects the file type, so it opens immediately. I did some investigation, and found that after opening/saving the xlsx file with Excel, the _rels/.rels file is changed (by Excel) to remove the leading slashes from the Target property of the Relationship tag. If I take the file generated by the code below, and manually remove the leading slashes from the Target entries in the _rels/.rels file, the file is openable by OpenOffice. When looking at the ECMA-376 docs, page 67, it shows the Relationship/Target entries without leading slashes on them. So I believe POI is creating files that aren't valid with respect to the Target tag. Excel seems to be lenient in reading them, (and removing the badness when re-saving), and OpenOffice is just failing completely upon trying to parse the files. I will attach two xlsx files. One generated by the code below that cannot be opened by OpenOffice (test-bad.xlsx) and one that has been manually fixed that can be opened by OpenOffice (test-fixed.xlsx). I looked into trying to fix POI to remove the leading slashes, but I quickly ran into some issues with the code in openxml4j which has special checking to make SURE these entries have leading slashes! (Line 391 in org.apache.poi.openxlm4j.opc.PackagePartName.java) Sample code to generate a workbook. (Every workbook I have generated with POI 3.5-beta6 cannot be opened by OpenOffice in my testing) try { XSSFWorkbook wb = new XSSFWorkbook(); Sheet sheet = wb.createSheet(); OutputStream out = new FileOutputStream(new File("test-bad.xlsx")); wb.write(out); out.flush(); out.close(); } catch (Exception e) { e.printStackTrace(); } _rels/.rels contents that OpenOffice errors parsing: <?xml version="1.0" encoding="UTF-8"?> <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"> <Relationship Id="rId1" Target="/xl/workbook.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"/> <Relationship Id="rId2" Target="/docProps/core.xml" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"/> </Relationships> _rels/.rels contents that makes OpenOffice able to read files (only removed leading slashes from Target entries): <?xml version="1.0" encoding="UTF-8"?> <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"> <Relationship Id="rId1" Target="xl/workbook.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"/> <Relationship Id="rId2" Target="docProps/core.xml" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"/> </Relationships> Thanks, --Leif
Created attachment 23885 [details] xlsx file that has been "fixed" to be readable by OpenOffice
*** This bug has been marked as a duplicate of bug 46419 ***
Leif, I suggest you vote for this bug on openoffice.org: http://www.openoffice.org/issues/show_bug.cgi?id=97460 According to their rules, additional vote should prioritize this bug to an upper level. I hope it will influence OO developers to fix it. Regards, Yegor
Yegor, I added as many votes as I could for the OpenOffice issue. Thanks! --Leif