Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
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
Re: adding worksheet using parse excel::saveparser
by roboticus (Canon) 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 (Pilgrim) 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 (Pilgrim) 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 chilling in the Monastery: (8)
As of 2014-09-18 23:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (127 votes), past polls