One typo in your code might cause the problem:
should be$workbook = Spreadsheet::WriteExcel>new('FAISTATS_'."$Month".'.xls');
$workbook = Spreadsheet::WriteExcel->new('FAISTATS_'."$Month".'.xls');
When I corrected this and ran it under use strict; (a few declarations are needed...), it created a file with the desired sheets.
use warnings; use strict; use Spreadsheet::WriteExcel; use Spreadsheet::ParseExcel; use Spreadsheet::ParseExcel::SaveParser; my $Month = 9; my @s; sub create_excel { my $workbook = Spreadsheet::WriteExcel->new('FAISTATS_'."$Month".'.x +ls'); for ( my$i=1;$i<=8;$i++) { $s[$i] = $workbook->add_worksheet( "rpzea0".$i."a001" ) ; } } create_excel();
In reply to Re: Not able to create worksheets inside a subroutine
by hdb
in thread Not able to create worksheets inside a subroutine
by devbond
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |