Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

adding worksheet using parse excel::saveparser

by devbond (Novice)
on May 22, 2014 at 13:27 UTC ( #1087103=perlquestion: print w/replies, xml ) Need Help??
devbond has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to add a worksheet into an existing workbook using save parser but the worksheet doesnt get added though the program doesnt give any error. Please help
@month_name{ 0 .. 11 } = qw(Jan Feb Mar Apr May Jun Jul Aug Sept Oct N +ov Dec); my ( $day, $month, $year ) = (localtime)[ 3, 4, 5 ]; $year = $year + 1900; my $date=qx(echo "$day-$month_name{$month}-$year"); my $Month=qx(echo "$month_name{$month}-$year"); $date=~ s/^\s+|\s+$//g; print $date; $Month=~ s/^\s+|\s+$//g; print $Month; our $sheet_no; our $parser = Spreadsheet::ParseExcel::SaveParser->new(); our $workbook = $parser->Parse('MonitoringReport_'."$Month".'. +xls'); $workbook= $workbook->AddWorksheet("report",);

Replies are listed 'Best First'.
Re: adding worksheet using parse excel::saveparser
by roboticus (Chancellor) on May 22, 2014 at 14:48 UTC


    Have you tried telling $parser to save the workbook? I don't see such code in your example.


    When your only tool is a hammer, all problems look like your thumb.

Re: adding worksheet using parse excel::saveparser
by fishmonger (Chaplain) on May 22, 2014 at 15:51 UTC

    Part of the problem could be this line:

    $workbook= $workbook->AddWorksheet("report",);

    Try removing the comma, or add the missing %properties parameter

    Related module documentation:

        $workbook = $workbook->AddWorksheet($name, %properties);
    Create a new Worksheet object of type Spreadsheet::ParseExcel::Worksheet.
    The %properties hash contains the properties of new Worksheet.
Re: adding worksheet using parse excel::saveparser
by fishmonger (Chaplain) on May 22, 2014 at 16:19 UTC


    You're using a very verbose, awkward, and not very portable method of assigning your date vars.

    A much cleaner and portable method would be to use the strftime function from the POSIX module

    use POSIX qw(strftime); my $Month = strftime("%b-%Y", localtime); my $date = strftime("%d-%b-%Y", localtime);

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1087103]
Approved by Corion
[1nickt]: I had no idea how bad it could be.

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2018-01-18 22:09 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (215 votes). Check out past polls.