I have a macro enabled excel file which is getting corrupted during workbook.write The excel file being used is version MS office 2002(10.6866.6867)SP3 There are no exception thrown from POI. However few macros are getting emptied during the download. The file contains 8 charts 33 Sheets 1 User Form 19 Macros Out of this 3 macros getting emptied when interfaced with POI(3.6). Also tried testing with POI 3.7 binaries which is corrupting a few charts and sheets as well along with the Macros. The download has been tested in Windows XP\Windows Vista\Red Hat Linux ES. The behavior is the same. Other simular template files are getting downloaded without issues. It will be great if any know issues related to macros interface with POI. Curretly this is a blocker for the application development to proceed any further. Thanks in advance. Regards, Pradeep
You must set the "preserve nodes" flag to true when opening a macro containing workbook that you wish to write out again later See the java docs, eg http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFWorkbook.html#HSSFWorkbook(org.apache.poi.poifs.filesystem.POIFSFileSystem,%20boolean)
Dear Nick, The implementaion calls following constructor. To my //passed ByteArrayInputStream, preseve node true. new HSSFWorkbook(inp, true);
Dear Nick, The implementaion calls following constructor create workbook object. //passed ByteArrayInputStream, preseve node true. new HSSFWorkbook(inp, true); Any further inputs? Thanks & Regards, Pradeep
(In reply to comment #1) > You must set the "preserve nodes" flag to true when opening a macro containing > workbook that you wish to write out again later > See the java docs, eg > http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFWorkbook.html#HSSFWorkbook(org.apache.poi.poifs.filesystem.POIFSFileSystem,%20boolean) Dear Nick, The implementaion calls following constructor create workbook object. //passed ByteArrayInputStream, preseve node true. new HSSFWorkbook(inp, true); Any further inputs? Thanks & Regards, Pradeep
Please upload the input file with macros. Without the problematic file we can't do much to help you. Yegor (In reply to comment #4) > (In reply to comment #1) > > You must set the "preserve nodes" flag to true when opening a macro containing > > workbook that you wish to write out again later > > See the java docs, eg > > http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFWorkbook.html#HSSFWorkbook(org.apache.poi.poifs.filesystem.POIFSFileSystem,%20boolean) > > Dear Nick, > > The implementaion calls following constructor create workbook object. > > //passed ByteArrayInputStream, preseve node true. > new HSSFWorkbook(inp, true); > > Any further inputs? > > Thanks & Regards, > Pradeep
Dear Yegor, The file containg issue with workbook.write is intellectual property of my customer so I will not be able to share. So I am marking the bug as resolved. Thanks & Regards, Pradeep (In reply to comment #5) > Please upload the input file with macros. Without the problematic file we can't > do much to help you. > > Yegor > > (In reply to comment #4) > > (In reply to comment #1) > > > You must set the "preserve nodes" flag to true when opening a macro containing > > > workbook that you wish to write out again later > > > See the java docs, eg > > > http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFWorkbook.html#HSSFWorkbook(org.apache.poi.poifs.filesystem.POIFSFileSystem,%20boolean) > > > > Dear Nick, > > > > The implementaion calls following constructor create workbook object. > > > > //passed ByteArrayInputStream, preseve node true. > > new HSSFWorkbook(inp, true); > > > > Any further inputs? > > > > Thanks & Regards, > > Pradeep
You may be able to use the Microsoft Binary File Format Validator to identify what's wrong with the file, and potentially share that without revealing the file details. I'm told that the tool will be released publicly very soon now... See http://blogs.msdn.com/b/officeinteroperability/archive/2011/02/16/microsoft-office-binary-file-format-validation.aspx for details on it.