Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

I want to use the MS Excel's data analysis tool to deal with some data in excel.

by volunteer2003 (Initiate)
on Jun 10, 2012 at 14:22 UTC ( [id://975450]=perlquestion: print w/replies, xml ) Need Help??

volunteer2003 has asked for the wisdom of the Perl Monks concerning the following question:

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, , Fa +lse # 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'; }

Replies are listed 'Best First'.
Re: I want to use the MS Excel's data analysis tool to deal with some data in excel.
by davies (Prior) on Jun 10, 2012 at 14:45 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://975450]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (7)
As of 2024-04-23 13:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found