Jul 9, 2013, 6:58 AM
Post #2 of 2
The error message is indicating that this line failed.
Re: [giridhar276] Unable to create spreadsheet in cgi script
[In reply to]
i.e., $workbook is undefined. You should test for that before creating the worksheet.
my $workbook = Excel::Writer::XLSX->new("$report_name");
defined $workbook or die "Problems creating new Excel file: $!";
1) You're missing 2 very important pragmas, which should be in every Perl script you write. Add these pragmas and declare all of your vars (like you did with $workbook).
2) Why are you loading CGI twice?
3) Why are you assigning $report_year twice?
4) No need to use concatenation when assigning $report_name, it just adds unnecessary clutter.
my $report_name = "Network_Availability_Report_$report_month_$report_year.xlsx";
5) Since you're loading the CGI module, why not use its methods to output the html? Doing so would cleanup that portion.
6) Don't quote single vars unnecessarily.
See perldoc -q quoting http://perldoc.perl.org/perlfaq4.html#What%27s-wrong-with-always-quoting-%22$vars%22?
e.g., instead of: