Community
Participate
Working Groups
Created attachment 283392 [details] Original and Corrupted files We have a problem with the Excel integration on Excel 2016 Windows 10, the file gets corrupted if it is saved twice in the same session. We use org.eclipse.swt.ole.win32.OleClientSite.save(File, boolean) to save the file. Sceanario: 1. Open Excel editor 2. Modify content and save - Everything is ok, content is saved. 3. Modify again and save - The resulting file is corrupted and can't be open in Excel. It only happens in Excel 2016 on older Excel version it works. The problem can be reproduced also if call twice org.eclipse.swt.ole.win32.OleClientSite.save consecutively Note: We observed that if the user press Save in the Excel toolbar after OleClientSite.save call the problem doesn't occur. I attached some test files, if the corrupted file is unpacked we can see that some internal sheet files are missing We integrated it using: File exportFile = getExcelFile(); Preconditions.checkArgument(exportFile != null, "Excel could not be opened, file was null"); oleSite = new OleControlSite(frame, SWT.NONE, PROGRAM_ID, exportFile); oleSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE); OleAutomation excelSheet = new OleAutomation(oleSite); int[] dispIDs = excelSheet.getIDsOfNames(new String[] {APPLICATION_ID }); Variant pVarResult = excelSheet.getProperty(dispIDs[0]); oleApplication = pVarResult.getAutomation(); pVarResult.dispose(); excelSheet.dispose();
I have the same issue with target platform 4.19 and added a SWT-Test to show the Bug.
Created attachment 286561 [details] SWT-Test (Excel Bug) File size is different after sec. save call of excel files: // Word // 391419 =?= 391285 // 1. OK // 391419 =?= 391212 // 2. OK // 391419 =?= 391212 // 3. OK // Excel // 11861 =?= 15018 // 1. OK // 11861 =?= 4103 // 2. Bug // 11861 =?= 4103 // 3. Bug
This hack solved the issue https://bugs.eclipse.org/bugs/show_bug.cgi?id=567798 // call private saveToStorageFile() to prevent OleClientSite.saveOffice2007() being called Method method; try { method = OleClientSite.class.getDeclaredMethod("saveToStorageFile", File.class); method.setAccessible(true); method.invoke(site, fileOut); } catch (Exception e) { e.printStackTrace(); }