Bug 51391 - Macros gets altered/deleted while writing.
Summary: Macros gets altered/deleted while writing.
Status: RESOLVED WONTFIX
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.6-FINAL
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-17 10:50 UTC by Pradeep Nair
Modified: 2011-06-21 12:55 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pradeep Nair 2011-06-17 10:50:07 UTC
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
Comment 1 Nick Burch 2011-06-17 10:58:28 UTC
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)
Comment 2 Pradeep Nair 2011-06-18 11:59:24 UTC
Dear Nick,

The implementaion calls following constructor. To my 

//passed ByteArrayInputStream, preseve node true.
new HSSFWorkbook(inp, true);
Comment 3 Pradeep Nair 2011-06-18 12:01:11 UTC
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
Comment 4 Pradeep Nair 2011-06-20 10:21:12 UTC
(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
Comment 5 Yegor Kozlov 2011-06-20 16:47:45 UTC
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
Comment 6 Pradeep Nair 2011-06-21 06:54:12 UTC
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
Comment 7 Nick Burch 2011-06-21 12:55:12 UTC
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.