#use strict; use Win32::OLE::Const 'Microsoft Excel'; use CGI; #get the data from the form my $q = new CGI; my $matchDay = $q->param(matchDay); my $matchMonth = $q->param(matchMonth); my $matchYear = $q->param(matchYear); my $challenger = $q->param(challenger); my $cRow = $q->param(cRow); my $opponent = $q->param(opponent); my $oRow = $q->param(oRow); my $g1c = $q->param(g1c); my $g1o = $q->param(g1o); my $g2c = $q->param(g2c); my $g2o = $q->param(g2o); my $g3c = $q->param(g3c); my $g3o = $q->param(g3o); my $g4c = $q->param(g4c); my $g4o = $q->param(g4o); my $g5c = $q->param(g5c); my $g5o = $q->param(g5o); #open excel my $Excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); #open the spreadsheet... used to use visible=1 for my own #editing purposes $Excel->{'Visible'}=0; my $book = $Excel->Workbooks->Open("D:\\andreas\\perl\\squash.xls") || die("Unable to open document ", Win32::OLE->LastError()); #add a temporary sheet to stick the form data (Sheet1) by #default my $worksheet = $book->Worksheets->Add; $worksheet->Range(A1)->{'value'} = $matchDay; $worksheet->Range(A2)->{'value'} = $matchMonth; $worksheet->Range(A3)->{'value'} = $matchYear; $worksheet->Range(A4)->{'value'} = $challenger; $worksheet->Range(A5)->{'value'} = $cRow; $worksheet->Range(A6)->{'value'} = $opponent; $worksheet->Range(A7)->{'value'} = $oRow; $worksheet->Range(A8)->{'value'} = $g1c; $worksheet->Range(A9)->{'value'} = $g1o; $worksheet->Range(A10)->{'value'} = $g2c; $worksheet->Range(A11)->{'value'} = $g2o; $worksheet->Range(A12)->{'value'} = $g3c; $worksheet->Range(A13)->{'value'} = $g3o; $worksheet->Range(A14)->{'value'} = $g4c; $worksheet->Range(A15)->{'value'} = $g4o; $worksheet->Range(A16)->{'value'} = $g5c; $worksheet->Range(A17)->{'value'} = $g5o; #run excel macros that adds the new data $Excel->Run("Start"); #remove the temporary sheet $Excel->{'DisplayAlerts'}=False; $worksheet->Delete; $Excel->{'DisplayAlerts'}=True; #run the macro in excel that generates the rankings my $worksheet = $book->Worksheets("Summary"); $worksheet->Select; $Excel->Run("updateStats"); $book->Save; $book->Close;