You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Larry Johnson <la...@lgjconsulting.com> on 2004/06/03 03:54:46 UTC

Troubles modifing excel file with macros

Hi,

 

I'm trying to use HSSF to add data to an excel file that has macros.

So far I have simple java applications working and creating excel files
using POI.

The trouble I'm having is when I try reading in an excel file with macros
and then try to immediately write it back out. In this test I don't even try
to modify anything. 

The output I expect is the exact same file written back out.

But what happens is the file is over 2 times the size of the original file.
Then when I try to open it in excel 2003 it claims that the file is
corrupted and tries to recover the contents. The end result is a excel file
with only data and no macros and formatting.

I found in the POI documentation stating that modifying an excel file leaves
the existing macros intact.

 

Can someone shed some light on this. 

Also, I'm using the HSSF.java to do my testing with.

 

I'm invoking it after successfully compiling like this.

 

java -classpath .:poi-2.5-final-20040302.jar HSSF liab_testRW.xls
liab_testRW.xls modify1

 

The file size of liab_testRW.xls before I run this is

 


-rw-r--r--    1 root     root       388608 Jun  2 18:32 liab_testRW.xls

 

And then after I run my test program it is

 

-rw-r--r--    1 root     root       834048 Jun  2 18:32 liab_testRW.xls

 

 

Any help is much appreciated!!

 

Thanks,

 

Larry

 


AW: Troubles modifing excel file with macros

Posted by Karl-Heinz Zengerle <ka...@sawag.com>.
Hi Larry.

The corruption effect we also had. The Excel template file was made by
copying and changing in Excel. Rebuilding the Excel file from the scratch in
Excel removed the problems. Excel files seem to have some awful form of
memorizing.

POI doesn't handle macros but doesn't remove them. So it's most probably a
consequence of the Excel message.

The size effect is new for me. What I could imagine as a reason is that
several cells are empty and consuming no memory in the file and that during
that process memory is consumed. But I'm no implementor of POI modules.

Regards,	Karl-Heinz.


-----Ursprungliche Nachricht-----
Von: Larry Johnson [mailto:larry@lgjconsulting.com]
Gesendet: Donnerstag, 3. Juni 2004 03:55
An: poi-user@jakarta.apache.org
Cc: larry.johnson@lgjconsulting.com
Betreff: Troubles modifing excel file with macros


Hi,



I'm trying to use HSSF to add data to an excel file that has macros.

So far I have simple java applications working and creating excel files
using POI.

The trouble I'm having is when I try reading in an excel file with macros
and then try to immediately write it back out. In this test I don't even try
to modify anything.

The output I expect is the exact same file written back out.

But what happens is the file is over 2 times the size of the original file.
Then when I try to open it in excel 2003 it claims that the file is
corrupted and tries to recover the contents. The end result is a excel file
with only data and no macros and formatting.

I found in the POI documentation stating that modifying an excel file leaves
the existing macros intact.



Can someone shed some light on this.

Also, I'm using the HSSF.java to do my testing with.



I'm invoking it after successfully compiling like this.



java -classpath .:poi-2.5-final-20040302.jar HSSF liab_testRW.xls
liab_testRW.xls modify1



The file size of liab_testRW.xls before I run this is




-rw-r--r--    1 root     root       388608 Jun  2 18:32 liab_testRW.xls



And then after I run my test program it is



-rw-r--r--    1 root     root       834048 Jun  2 18:32 liab_testRW.xls





Any help is much appreciated!!



Thanks,



Larry





---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org