- 论坛徽章:
- 0
|
函数calc_XXX 在windows 系统下直接进行运行(C:\Users\LF>perl test_1.pl)是可以的,但是在用IE打开相应CGI页面时就会报错,错误日志如下:
[Mon Jun 04 22:33:59 2012] [error] [client 127.0.0.1] Premature end of script headers: qynjjjyjpjhsgj.cgi, referer: http://127.0.0.1/cgi-bin/qynjjjyjpjhsgj.cgi
[Mon Jun 04 22:33:59 2012] [error] [client 127.0.0.1] OLE exception from "Microsoft Office Excel":, referer: http://127.0.0.1/cgi-bin/qynjjjyjpjhsgj.cgi
[Mon Jun 04 22:33:59 2012] [error] [client 127.0.0.1] , referer: http://127.0.0.1/cgi-bin/qynjjjyjpjhsgj.cgi
[Mon Jun 04 22:33:59 2012] [error] [client 127.0.0.1] \xb2\xbb\xc4\xdc\xc8\xa1\xb5\xc3\xc0\xe0 AddIns \xb5\xc4 Add \xca\xf4\xd0\xd4, referer: http://127.0.0.1/cgi-bin/qynjjjyjpjhsgj.cgi
[Mon Jun 04 22:33:59 2012] [error] [client 127.0.0.1] , referer: http://127.0.0.1/cgi-bin/qynjjjyjpjhsgj.cgi
[Mon Jun 04 22:33:59 2012] [error] [client 127.0.0.1] Win32::OLE(0.1709) error 0x800a03ec, referer: http://127.0.0.1/cgi-bin/qynjjjyjpjhsgj.cgi
[Mon Jun 04 22:33:59 2012] [error] [client 127.0.0.1] in METHOD/PROPERTYGET "Add" at C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/qynjjjyjpjhsgj.cgi line 1427, referer: http://127.0.0.1/cgi-bin/qynjjjyjpjhsgj.cgi
系统出错的行是:
$excel->AddIns->Add( "$xll_path" );
主要的目的就是想用CGI调用Excel , 其实后台调用Excel数据分析器进行数据计算。
请问大家遇到过这个问题吗?
详细代码如下:sub calc_XXX {
my $lib_root = catfile( $ENV{ProgramFiles},
'Microsoft Office', qw(OFFICE12 Library Analysis) );
#print "1---$lib_root\n";
my $xll_path = catfile $lib_root, 'ANALYS32.XLL';
#print "2---$xll_path\n";
my $xla_path = catfile $lib_root, 'ATPVBAEN.XLAM';
#print "3---$xla_path\n";
my $excel = get_excel();
#$excel->{Visible} = 1;
#sleep(5);
my $book = $excel->Workbooks->Open($JSGCB_13);
$book->RunAutoMacros(1);
my $sheet = $book->Worksheets(1);
# count the data line num
my $flag_counter = -1;
my $row = 5;
# for calc the line num
while ($flag_counter ne '0') {
$flag_counter = 0;
# check column 1 for the existing line
if (defined $sheet->Cells($row,1)->{'Value'}) {
$flag_counter ++;
} else {
last;
}
$row ++;
}
my $row_num = $row - 1;
my $str_1_1 = '$AQ$5AQ$'.$row_num;
my $str_1_2 = '$AU$5AV$'.$row_num;
my $str_2_1 = '$AQ$5AQ$'.$row_num;
my $str_2_2 = '$AS$5AT$'.$row_num;
my $str_3_1 = '$AQ$5AQ$'.$row_num;
my $str_3_2 = '$AR$5AS$'.$row_num;
$excel->AddIns->Add( "$xll_path" );
$excel->RegisterXLL( 'Analys32.xll' );
my $atp_book = $excel->Workbooks->Open( $xla_path );
$atp_book->RunAutoMacros(1);
$sheet = $book->Worksheets(1);
#sleep(5);
# Application.Run "ATPVBAEN.XLA!Regress", ActiveSheet.Range(Cells(2, 2), Cells(i, 2)), ActiveSheet.Range(Cells(2, 3), Cells(i, j)), False, False, , ActiveSheet.Range("$H$26", False, False, False, False, , False
# for C-L
$excel->Run(qq{ATPVBAEN.XLAM!Regress},
$sheet->Range($str_1_1),
$sheet->Range($str_1_2),
0,0,95,'C-L',1,1,1,1,1,1);
# for H-M
$excel->Run(qq{ATPVBAEN.XLAM!Regress},
$sheet->Range($str_2_1),
$sheet->Range($str_2_2),
0,0,95,'H-M',1,1,1,1,1,1);
# for T-M
$excel->Run(qq{ATPVBAEN.XLAM!Regress},
$sheet->Range($str_3_1),
$sheet->Range($str_3_2),
0,0,95,'T-M',1,1,1,1,1,1);
$excel->{DisplayAlerts} = 0;
if (-e $JSGCB_14) {
unlink $JSGCB_14;
}
#sleep(5);
# save and exit
$book->SaveAs($JSGCB_14);
$book->close;
undef $book;
undef $excel;
#system ('cmd');
#exec 'cmd';
} |
|