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

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.

  • Comment on Re^5: Not able to create worksheets inside a subroutine

Replies are listed 'Best First'.
Re^6: Not able to create worksheets inside a subroutine
by devbond (Novice) on Sep 29, 2013 at 18:02 UTC
    #!/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
      Try adding $workbook->close() as last statement.
      poj
      What does not work?