The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> The question for referenced MS Excel's data analysis tool in cgi
volunteer2003@126.com
post Jun 5 2012, 09:23 PM
Post #1





Group: Members
Posts: 1
Joined: 5-June 12
Member No.: 17,228



I want to use the MS Excel's data analysis tool to deal with some data in excel. So I used :
$excel->AddIns->Add( "$xll_path" );
$excel->RegisterXLL( 'Analys32.xll' );

The code is pass when I do 'C:\Users\LF>perl test_1.pl' , but there is a error info when I open the cgi by IE.

What can I do next? Thanks a lots for all your help!!!!!!!!!!!!!


ERROR INFO:
[Mon Jun 04 22:32:02 2012] [error] [client 127.0.0.1] in METHOD/PROPERTYGET "SaveAs" at C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/qynjjjyjpjhsgj.cgi line 1372, referer: http://127.0.0.1/cgi-bin/qynjjjyjpjhsgj.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

The code:
sub calc_all_14 {

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$5:$AQ$'.$row_num;
my $str_1_2 = '$AU$5:$AV$'.$row_num;

my $str_2_1 = '$AQ$5:$AQ$'.$row_num;
my $str_2_2 = '$AS$5:$AT$'.$row_num;

my $str_3_1 = '$AQ$5:$AQ$'.$row_num;
my $str_3_2 = '$AR$5:$AS$'.$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';
}


User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th April 2024 - 08:38 AM