Created attachment 23038 [details] Saved xlsx file using the specified code. Very simple xlsx file. Open Office 3.0 don't recognize it Using this code to load an xlsx file and save it in another path with o without changes. Workbook xlsDocument=null; try { xlsDocument = WorkbookFactory.create(new FileInputStream(pathOriginal)); } catch (FileNotFoundException ex) { ex.printStackTrace(); } catch (Exception ex) { ex.printStackTrace(); } FileOutputStream fos = new FileOutputStream(pathTemp); xlsDocument.write(fos); fos.flush(); fos.close(); The saved file contains file format errors. If the saved file is a complex file, when you try to open it with excel, it says that the file is damaged but sometimes can repair it. With simples files (including the most simple file, only one cell with a simple text content) excel can open the file without errors. But if you try to open the saved file using OpenOffice 3.0 which supports xlsx file format. OpenOffice 3.0 can open the original xlsx file without problems, but the saved file isn't recognized by OpenOffcie 3.0. If you open the saved file with excel and save it again (usign save option from excel), now OpenOffice can open it without problems, so I supose that exists a save bug that causes a format problem that usually can be repaired by excel, but never can be repaired by OpenOffice.
Please attach the original file. Yegor
I think it is a bug in OpenOffice, not in POI. I files and issue, let's wait for feedback from OO guys: http://www.openoffice.org/issues/show_bug.cgi?id=97460 Description: OpenOffice can't read core OOXML relationships if a part name starts with a forward slash character '/'. For example, if the main document part is referenced as "/xl/workbook.xml" then OpenOffice Calc fails to open it. If the main part is referenced as "xl/workbook.xml" (without the leading slash), then the file is opened OK. The part name grammar implies the forward slash constraint. See OOXML Open Packaging Conventions, Package model conformance requirements: M1.4 A part name shall start with a forward slash (“/”) character. This constraint doesn't seem to be mandatory. Excel 2007 writes package part names without the leading slash and doesn't require it when reading files. Both "xl/workbook.xml" and "/xl/workbook.xml" part names seem to be valid, although only the first one is OK in OpenOffice 3.0. So, I think OO should support package part names starting with a forward slash. Yegor
Sorry for not responding, but I was on holiday. I agree that can exist an OpenOffice bug as you say, but I think that the bug I reported is a POI bug too. If I open an original file with MS Excel 2007 it works properly, but if I save this file without changes using POI the saved file not only can't be opened by OpenOffice but also presents problems to be opened with MS Excel 2007. Excel can open it, but it has to delete some registers, so I think that exists a problem with Apache POI too. This is the messages reported by Excel 2007 when I try to open the saved file: Registros quitados: Información de celda de /xl/worksheets/sheet6.xml parte Registros quitados: Fórmula de /xl/calcChain.xml parte (Propiedades de cálculo) The message is in spanish, in English it could be translated as: Deleted registers: Cell information of /xl/worksheets/sheet6.xml part Deleted registers: Formula of /xl/calcChain.xml part (Calculation of properties) I can't attach my original file because it contains some private information, but I will try to modify this file to delete this private information and attach it. The file is protected so I can't modify it, when I get the password to unprotect and modify it I will attach the file. Sorry. J. Miguel
Created attachment 23159 [details] Original xlsx fiel (before saving)
Created attachment 23160 [details] Saved file using Apache POI. No changes from the original file Open office can´t open this file.
I attached the Original file and the saved file which I have the problem. I can open the saved file with Office Excel, but not with OpenOffice Calc. I only opened and saved the the file without changes and in a different path. Sorry but we had a lot of problems to can unprotect the file and publish it. Thanks.
*** Bug 47432 has been marked as a duplicate of this bug. ***
I wrote a simple java class to work around this issue and make the xlsx files generated by POI compatible with OpenOffice. We use it when generating all of our xlsx files as an interim solution while the OpenOffice bug sits there and does nothing :-) It is attached as OpenOfficeXlsxRepair.java --Leif
Created attachment 24027 [details] OpenOfficeXlsxRepair.java - simple java class that works around OpenOffice issues - uses truezip: https://truezip.dev.java.net/
(In reply to comment #9) > Created an attachment (id=24027) [details] > OpenOfficeXlsxRepair.java - simple java class that works around OpenOffice > issues FYI. This class uses truezip to manipulate the contents of the xlsx zip file: https://truezip.dev.java.net/
I fixed POI to produce files compatible with OpenOffice. The fix was committed in r797350 Yegor
Thank you Yegor! I will remove my workaround for around this :-) --Leif
Thanks Yegor and Leif for solving the bug.