You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2010/11/24 23:12:47 UTC
DO NOT REPLY [Bug 50331] New: Writing HSSFWorkbook with macro causes
lost macro project
https://issues.apache.org/bugzilla/show_bug.cgi?id=50331
Summary: Writing HSSFWorkbook with macro causes lost macro
project
Product: POI
Version: 3.7
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: major
Priority: P2
Component: HSSF
AssignedTo: dev@poi.apache.org
ReportedBy: steve@ebiggs.ca
Created an attachment (id=26336)
--> (https://issues.apache.org/bugzilla/attachment.cgi?id=26336)
Sample Excel file with macro
Overview:
Opening existing HSSFWorkbook that was created using Excel and contains a macro
and then writing the workbook to a new file causes the macro project to be lost
when opening the spreadsheet in Excel.
Steps to Reproduce:
1. Create a workbook using Excel application. Create a macro within the
workbook.
2. Access workbook in Java using new HSSFWorkbook().
3. Write the workbook (no changes need to be made) to a new file.
4. Open newly saved workbook in Excel application. Select enabled macros when
prompted.
Actual Results:
Excel opens and presents security warning asking whether to enable or disable
macros (this is normal). After selecting enable macros Excel presents a dialog
that says "File not found". Click ok on this dialog and Excel presents a new
dialog that says "Excel found unreadable content in "test out.xls". Do you
want to recover the contents of this workbook? If you trust the source of this
workbook, click Yes." After clicking yes Excel presents another security
warning. Click enable macros and a final dialog reports "Errors were detected
in "test out.xls" but Microsoft Office Excel was able to open the file by
making the repairs listed below.". The repair listed in the dialog is "Lost
Visual Basic project". Close this dialog.
The contents of the worksheet appear correct, but go to Tools->Macro->Visual
Basic Editor and the VBA project is gone.
Expected Results:
Excel should open the file without any errors. The VBA project should be
accessible.
Build Date & Platform:
POI 3.7 beta3 2010-09-24
Windows XP Service Pack 3
Microsoft Office Excel 2003 SP3 (11.8324.8324)
Additional Information:
Attached sample Excel file.
Java sample code:
public class TestHSSF {
public static void main(String[] args) throws IOException {
InputStream inputFile=null;
FileOutputStream outputFile=null;
inputFile=new FileInputStream("C:\\Documents and
Settings\\Administrator\\Desktop\\test.xls");
HSSFWorkbook wb=new HSSFWorkbook(new POIFSFileSystem(inputFile),false);
outputFile=new FileOutputStream("C:\\Documents and
Settings\\Administrator\\Desktop\\test out.xls");
wb.write(outputFile);
outputFile.close();
inputFile.close();
}
}
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
DO NOT REPLY [Bug 50331] Writing HSSFWorkbook with macro causes lost
macro project
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50331
Steve Biggs <st...@ebiggs.ca> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |steve@ebiggs.ca
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
DO NOT REPLY [Bug 50331] Writing HSSFWorkbook with macro causes lost
macro project
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50331
Yegor Kozlov <ye...@dinom.ru> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
--- Comment #1 from Yegor Kozlov <ye...@dinom.ru> 2010-12-12 07:25:59 EST ---
Pass 'true' as the second parameter in the constructor HSSFWorkbook(InputStream
is, boolean preserveNodes) and you will be good. Or better use the default
constructor HSSFWorkbook(InputStream is).
Excel file is a compound OLE2 document and the workbook stream and macros are
nodes of the OLE2 document. The second boolean parameter tells POI whether to
preserve nodes other than Workbook, such as macros. Passing 'false' truncates
the OLE2 file system to only the Workbook stream and document properties which
is exactly what is happening in your case.
Yegor
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org