I have saved an empty XLSX Dokument with
LibreOffice 4.3.6.2 .
I can open the created xlsx file in vaadin spreadsheet and edit. When i save the spreadsheet i get following exception:
Warnung: The part /xl/worksheets/_rels/sheet1.xml.rels does not have any content type ! Rule: Package require content types when retrieving a part from a package. [M.1.14]
org.apache.poi.openxml4j.exceptions.InvalidFormatException: The part /xl/worksheets/_rels/sheet1.xml.rels does not have any content type ! Rule: Package require content types when retrieving a part from a package. [M.1.14]
at org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:249)
at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:673)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:253)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:200)
at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:108)
at com.vaadin.addon.spreadsheet.SpreadsheetFactory.write(SpreadsheetFactory.java:296)
at com.vaadin.addon.spreadsheet.Spreadsheet.write(Spreadsheet.java:2183)
When i try to load the saved file which has been modified by spreadsheet, i get this Exception:
java.io.IOException: Invalid file format.
However, i can still open the saved file in LibreOffice again.
I hope you noticed
Apache POI bug #54803 , which gives the same error in a bit more special circumstances. If you didn’t do any special modifications to the file before saving, your case sounds like a rather basic use case, so the problem would be nasty. The bug been there for some time, but if it’s a POI issue, then that’s really where it should be fixed.
Its a basic use case indeed. The document created by LibreOffice is empty. Also there is no need to make any modifications in vaadin spreadsheet before saving to reproduce this bug.
I have noticed the reported bug, but its there already for a long time.
Ok yeah, I tried your code and the result is indeed a bit different, so the issue occurs in Spreadsheet. It seems that when Spreadsheet reads (probably) or writes the file, it adds a drawing object in the workbook, thereby causing the mentioned Apache POI bug to manifest.
There’s now Vaadin Spreadsheet
ticket #17372 about the issue. We can probably work that out, but the actual POI bug will probably emerge in situations where there’s actual drawings in the document. It may be caused by some missing content type and relationship declarations in the output. You’re welcome to encourage Apache POI developers to fix the issue.
I have used the same code specified in loadSaveWithPOI() method.
But I am getting exception java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.apache.poi.xssf.usermodel.XSSFWorkbook