【发布时间】:2015-08-01 13:24:55
【问题描述】:
这是我的 cgi 代码,perl.xls 文件作为脚本存在于保存文件夹中。
#!/usr/bin/perl
print "Content-type: text/html\n\n";
use CGI;
use DBI;
use Spreadsheet::WriteExcel;
use strict;
use warnings;
use CGI::Carp qw(fatalsToBrowser);
my $cgi = CGI->new;
my $workbook = Spreadsheet::WriteExcel->new('perl.xls');
my $worksheet = $workbook->add_worksheet();
$worksheet->write(0,0,'value');
当我运行脚本时出现此错误
Software error:
Can't call method "add_worksheet" on an undefined value at /var/www/cgi-bin/excel.cgi line 17.
For help, please send mail to the webmaster (root@localhost), giving this error message and the time and date of the error.
【问题讨论】:
-
检查
new()的返回值。my $workbook = Spreadsheet::WriteExcel->new('perl.xls') or die "can't open?"; -
@Сухой27 它的返回打不开..
-
@sp1rs 找出原因?
...or die can't open: $!;
标签: excel perl cgi perl-module cgi-bin