http://qs321.pair.com?node_id=39908

Item Description: To write a spreadsheet in native excel binary form

Review Synopsis: Very Useful module for me anyway :-)

To use this module
use Spreadsheet::WriteExcel;

As stated above this module allows you to write excel files
without that annoying popup asking you how your file is
delimeted when you open the file. It works very well,
the only problem i had was trying to convert one of our flat files
that is over 70,000 records in length. But after
i checked the problem is documented, it can only produce files
<~ 7.0 MB. heres on little program I have created with it

#!/usr/bin/perl use Spreadsheet::WriteExcel; print "Enter the path to the file(ie /home/): "; $path = <>; chomp($path); print "Enter the filename(ie data): "; $fname = <>; chomp($fname); $file = "$path$fname"; my $workbook = Spreadsheet::WriteExcel->new("/tmp/$fname.xls"); $worksheet1 = $workbook->addworksheet(sheet1); $worksheet2 = $workbook->addworksheet(sheet2); $worksheet3 = $workbook->addworksheet(sheet3); $format = $workbook->addformat(); $format->set_bold(); $format->set_color('black'); $format->set_align('center'); $format->set_size('10'); open input, "$file" || die "Can't open that file"; $k=0; for (<input>){ chomp($_); @data = split(/\t/,$_); for ($i=0; $i<=@data; $i++){ $worksheet1->write($k, $i, $data[$i], $format); } $k++; }
Good Luck
Rob

Replies are listed 'Best First'.
RE: Spreadsheet::WriteExcel
by nop (Hermit) on Nov 06, 2000 at 05:44 UTC
    I agree -- a great module, great docs. Even better now that it supports cell formatting.
    Minor minor minor gripe: the format objects appear bound to a specific sheet... that is, if you have multiple sheets open for writing, you cannot simply define one set of formats (eg fmt_important = bold and red, fmt_header = bold and underlined, etc) and apply them across the board to all open sheets. At least I couldn't get this to work... maybe I missed something.
    Overall, a fantastic piece of code.