Whenever i've used the Spreadsheet module, i also found it hard to create an Excel file from scratch, since the module doesn't handle formatting too well.
What i ended up doing was just creating my template and formatting in windows, then loading the template using Spreadsheet::ParseExcel. After that it's just a matter of writing and saving it using WriteExcel and SaveParser.
Here are some snippets from some code i had laying around. Hope this helps.
#excel modules
use Spreadsheet::ParseExcel::SaveParser;
use Spreadsheet::WriteExcel;
#loading template
my $parser = new Spreadsheet::ParseExcel::SaveParser;
my $template = $parser->Parse('timesheets/old_template.xls')
or die "Unable to open template";
my $temp_workbook;
#adding info...
#user name
setCellFormat(4,2);
$template->AddCell(0, 4, 2, "$real_name", $format);
#project name
setCellFormat(5,2);
$template->AddCell(0, 5, 2, "$project_name", $format);
#save data
my $workbook;
{ #ignore SaveAs errors and warnings
local $^W = 0;
$workbook = $template->SaveAs('/home/~myname/httpdocs/spreadsh
+eet.xls');
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.