CPAN Write Excel

G

Gallon

I have MS Excel spreadsheets with tons of formulas and data already in
them, so I was very excited about discovering
"Spreadsheet::WriteExcel". This would allow me to write data directly
from my Perl scripts, rather than cutting and pasting. The only
drawback, except for me being an idiot or a luddite, is the module only
seems to have a "new" constructor! I need an "open" constructor, or
whatever. Does anyone know how I might do this???

Sincerely,

Gregg Allen
 
G

Gordana

OK.
I use the Win32::OLE module, and I can create, and save file.
How to open existing Excel .XLS file?

Thanks.


--
 
T

Tad McClellan

The very first paragraph of the documentation for the module you
are using says:

This module cannot be used to write to an existing Excel file.
So far as I know, Spreadsheet::WriteExcel does exactly what it says: it
writes Excel files. It doesn't read them or update them.
Spreadsheet::parseExcel will read Excel files. Between the two, you
might be able to accomplish an update. I recommend, though, that you
check out the Win32::OLE module. It is more suitable for updating Excel
spreadsheets. There are Excel examples in the module documentation that
will get you started.


I needed to do this in a CGI program last week, but the web server
was not Redmondware, so no OLE.

Jakarta POI to the rescue!

http://jakarta.apache.org/poi/

Recalling enough Java to get it working made me spit, but it allowed
me to serve Excel files derived from an Excel "template" file.
 
C

Craig

Gordana said:
OK.
I use the Win32::OLE module, and I can create, and save file.
How to open existing Excel .XLS file?

Thanks.
Here is a simple example:

#!/C:/Perl/bin/perl.exe
use strict;
use warnings;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';
use Win32::OLE::Variant;
$Win32::OLE::Warn = 3;

my $excel = Win32::OLE->GetActiveObject('Excel.Application') ||
Win32::OLE->new('Excel.Application', 'Quit');
my $book = $excel->Workbooks->Open("C:\\TMP\\test1.xls");
my $sheet = $book->Worksheets(1);
my $aref = $sheet->Range("A1:D5")->{Value};
my $sheet2 = $book->Worksheets(2);
$sheet2->Range("A6:D10")->{Value} = $aref;
 
G

Gallon

Tad said:
The very first paragraph of the documentation for the module you
are using says:

This module cannot be used to write to an existing Excel file.



I needed to do this in a CGI program last week, but the web server
was not Redmondware, so no OLE.

Jakarta POI to the rescue!

http://jakarta.apache.org/poi/

Recalling enough Java to get it working made me spit, but it allowed
me to serve Excel files derived from an Excel "template" file.
*********************************************************************

"This module cannot be used to write to an existing Excel file"

I'm on a MAC. I should have read the documentation first instead of
just examining the code.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,290
Messages
2,571,454
Members
48,131
Latest member
AntoniaSep

Latest Threads

Top