shockme has asked for the wisdom of the Perl Monks concerning the following question:
I'd never used Spreadsheet::WriteExcel before, but it was a breeze. The spreadsheet is exactly the way management uses it. The only difference is the size of the file. The file created by my perl script is much larger than the file created by importing the comma delimited file. Here's the breakdown:
Following is the script I'm using to create the file. I'd like to hear any suggestions regarding reducing the size of the Excel file. Like I said, I've never played with the module before, so I may be missing some obvious efficiency issues.
#!/usr/bin/perl -w use strict; use Spreadsheet::WriteExcel::Big; open (IN, "temp.txt") || die "Cannot open temp.txt\n"; # set up Excel spreadsheet my $workbook = Spreadsheet::WriteExcel::Big->new("temp.xls"); my $worksheet = $workbook->addworksheet(); my $inLine; my $row = 0; while ($inLine = <IN>) { my ($date, $log, $protocol, $firstIP, $secondIP, $packets) = split(/,/, $inLine); # strip port number if it exists if ($firstIP =~ /([\d.]+)\((\d+)\)/) { my $ip1 = $1; my $port1 = $2; } else { my $ip1 = $firstIP; my $port1 = " "; } if ($secondIP =~ /([\d.]+)\((\d+)\)/) { my $ip2 = $1; my $port2 = $2; } else { my $ip2 = $secondIP; my $port2 = " "; } push my @XLSarray, ($date, $log, $protocol, $ip1, $port1, $ip2, $port2, $pac +kets); # print information to Excel spreadsheet my $col = 0; foreach my $XLSelement (@XLSarray) { $worksheet->write($row, $col, $XLSelement); $col++; } $row++; } $workbook->close();
If things get any worse, I'll have to ask you to stop helping me.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Spreadsheet::WriteExcel::Big is Bigger
by jmcnamara (Monsignor) on Jan 23, 2002 at 21:18 UTC | |
by shockme (Chaplain) on Jan 23, 2002 at 22:37 UTC | |
|
Re: Spreadsheet::WriteExcel::Big is Bigger
by talexb (Chancellor) on Jan 23, 2002 at 21:32 UTC | |
by shockme (Chaplain) on Jan 23, 2002 at 22:25 UTC |