Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

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",);

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

    devbond:

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

    ...roboticus

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

Re: adding worksheet using parse excel::saveparser
by fishmonger (Friar) 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:

    AddWorksheet()
    
        $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 (Friar) on May 22, 2014 at 16:19 UTC

    OT

    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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1087103]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2015-07-31 01:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (274 votes), past polls