Community
Participate
Working Groups
Steps to reproduce: - Download latest Eclipse IDE (2020-09) - Start Eclipse and create an empty project - copy new empty excel file to project - open excel file - make a change and save (WORKS) - make another change and save (FAILS, editor stays dirty and changes are not stored) java.runtime.version=14.0.2+12 eclipse.buildId=4.17.0.I20200902-1800 Microsoft Excel 2016 MSO
This issue remains in the current Eclipse 2021-03 (4.19.0).
The behavior is worse than originally stated, the editor not only stays dirty after the second save but corrupts the document. Steps to reproduce: - Download latest Eclipse IDE (2021-03) -> https://www.eclipse.org/downloads/packages/release/2021-03/r/eclipse-ide-java-developers - Start Eclipse and create an empty project - copy an excel file with content to the project (11’809 bytes) - open excel file - make a change and save (WORKS) (11’448 bytes) - make another change and save (FAILS, editor stays dirty and file is now corrupt) (3’399 bytes) Saving only once doesn't corrupt the document: - open - modify - save - close - open - modify - save - close
Also issue remains in current milestone release: Version: 2021-06 (4.20) Build id: I20210407-1800
Just came across this interesting code: OleClientSite.java public boolean save(File file, boolean includeOleInfo) { /* * Bug in Office 2007. Saving Office 2007 documents to compound file storage object * causes the output file to be corrupted. The fix is to detect Office 2007 documents * using the program ID and save only the content of the 'Package' stream. */ if (isOffice2007(false)) { return saveOffice2007(file); } if (includeOleInfo) return saveToStorageFile(file); return saveToTraditionalFile(file); } In my case isOffice2007() returns "true" even though using Office 2016. Which then ignores the includeOleInfo parameter.
This hack solved the issue in my case, the root of the problems seems to be the saveOffice2007(). // call private saveToStorageFile() to prevent OleClientSite.saveOffice2007() being called Method method = OleClientSite.class.getDeclaredMethod("saveToStorageFile", File.class); method.setAccessible(true); method.invoke(clientSite, file);