vxp has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use Spreadsheet::WriteExcel; use Spreadsheet::ParseExcel; my $oExcel = new Spreadsheet::ParseExcel; my $weekday = (Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturda +y)[(localtime)[6]-1] ; my $dayofmonth = (localtime)[3] - 1; my $month = (January, February, March, April, May, June, July, August, + September, October, November, December)[(localtime)[4]]; my $date = (localtime)[3] - 1; my $column = (localtime)[6] + 1; my $row = 2 + $dayofmonth; my $excelrow = $row + 1; my $aolstats; my $msnstats; my $wwwstats; my $aolfile = "/stats/aol"; my $msnfile = "/stats/msn"; my $wwwfile = "/stats/www"; ######################### # Get the stats ######################### open(AOLFILE, $aolfile) or die "Couldn't open AOL stats: $!\n"; $aolstats = <AOLFILE>; if ($aolstats =~ /\d{4}-\d{2}-\d{2}-aol\s+(.*)/) { $aolstats = $1; } open(MSNFILE, $msnfile) or die "Couldn't open MSN stats: $!\n"; $msnstats = <MSNFILE>; if ($msnstats =~ /\d{4}-\d{2}-\d{2}-msn\s+(.*)/) { $msnstats = $1; } open(WWWFILE, $wwwfile) or die "Couldn't open WWW stats: $!\n"; $wwwstats = <WWWFILE>; if ($wwwstats =~ /\d{4}-\d{2}-\d{2}-www\s+(.*)/) { $wwwstats = $1; } ################################ # Get rid of the comma in stats ################################ if ($aolstats =~ /(\d+),(\d+)/) { $aolstats = $1 . $2; } if ($msnstats =~ /(\d+),(\d+)/) { $msnstats = $1 . $2; } if ($wwwstats =~ /(\d+),(\d+)/) { $wwwstats = $1 . $2; } ################################ # Create the worksheets ################################ my $workbook = $oExcel->Parse('test2.xls'); #this is what i tried, doe +snt work #my $workbook = Spreadsheet::WriteExcel->new("test2.xls"); my $worksheet1 = $workbook->addworksheet('1st Quarter 2002'); my $worksheet2 = $workbook->addworksheet('2nd Quarter 2002'); my $worksheet3 = $workbook->addworksheet('3rd Quarter 2002'); my $worksheet4 = $workbook->addworksheet('4th Quarter 2002'); my $worksheet5 = $workbook->addworksheet('Daily Traffic 4th Quarter'); $worksheet3->activate(); # Worksheet that you see when you open up t +ext2.xls my $format = $workbook->addformat(); $format->set_bold(); $worksheet3->write(0, 0, "KATRILLION TRAFFIC 3rd QUARTER JULY-AUGUST-S +EPTEMBER", $format); $worksheet3->write(2, 0, 'Date', $format); $worksheet3->write(2, 1, 'Day', $format); $worksheet3->write(2, 2, 'AOL', $format); $worksheet3->write(2, 3, 'MSN', $format); $worksheet3->write(2, 4, 'Katrillion', $format); $worksheet3->write(2, 5, 'CS', $format); $worksheet3->write(2, 6, 'Daily Total', $format); $worksheet3->write(2, 7, 'AOL Weekly', $format); $worksheet3->write(2, 8, 'Mo. Run Total', $format); $worksheet3->write(2, 9, '% change', $format); $worksheet3->write($row, 0, "$month $date"); $worksheet3->write($row, 1, $weekday); $worksheet3->write($row, 2, $aolstats); $worksheet3->write($row, 3, $msnstats); $worksheet3->write($row, 4, $wwwstats); $worksheet3->write_formula($row, 6, "=SUM(C$excelrow:F$excelrow)" );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need help with opening up a Excel file then modifying it.
by jmcnamara (Monsignor) on Aug 21, 2002 at 14:18 UTC | |
| |
|
Re: Need help with opening up a Excel file then modifying it.
by Mr. Muskrat (Canon) on Aug 21, 2002 at 15:22 UTC | |
by Anonymous Monk on Aug 21, 2002 at 18:36 UTC | |
by Anonymous Monk on Aug 22, 2002 at 00:15 UTC | |
|
Re: Need help with opening up a Excel file then modifying it.
by ides (Deacon) on Aug 21, 2002 at 14:07 UTC | |
|