Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^4: Not able to create worksheets inside a subroutine

by devbond (Novice)
on Sep 29, 2013 at 16:53 UTC ( #1056238=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Not able to create worksheets inside a subroutine
in thread Not able to create worksheets inside a subroutine

I cant declare workbook as my as i need to use it in other subs too


Comment on Re^4: Not able to create worksheets inside a subroutine
Re^5: Not able to create worksheets inside a subroutine
by hdb (Prior) on Sep 29, 2013 at 17:42 UTC

    Then, at least, declare it as a globel variable, ie outside of all subs. Or, better, pass it as a parameter into the subs, that need it.

      #!/usr/bin/perl use warnings; use Spreadsheet::WriteExcel; use Spreadsheet::ParseExcel; use Spreadsheet::ParseExcel::SaveParser; my $workbook; my @s; $Month=Sept; sub create_excel { $workbook = Spreadsheet::WriteExcel->new('FAISTATS_'."$Month".'.xls'); for ( $i=1;$i<=8;$i++) { $s[$i] = $workbook->add_worksheet( "cpzea0".$i."a0001" ) ; } $s[9] = $workbook->add_worksheet( "WEEKLY" ) ; $s[10] = $workbook->add_worksheet( "MONTHLY" ) ; } create_excel();
      declaring workbook outside is not working
        What does not work?
        Try adding $workbook->close() as last statement.
        poj

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2015-07-04 01:43 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 (57 votes), past polls