dimmesdale has asked for the wisdom of the Perl Monks concerning the following question:
# All non-excel stuff taken out for your viewing ease ;) #!/usr/bin/perl -w use strict; use Spreadsheet::WriteExcel; use Spreadsheet::WriteExcel::Utility; ... my $file = 'test.txt'; open (TABFILE,$file) or die "$file: $!"; # Create a new Excel workbook my $workbook = Spreadsheet::WriteExcel->new('TEST2.xls'); my $worksheet = $workbook->addworksheet('all_avg'); my $group_avg = $workbook->addworksheet('gr_avg'); my $h_frmt = $workbook->addformat( border => 2, fg_color => 'silver', pattern => 1); my $headers1 = [ 'TS# and Condition', 'Rest HRT', 'IMC HRT', 'Rest SKT', 'IMC SKT', 'Rest EMG', 'IMC EMG' ]; my $headers2 = [ 'Condition', 'Rest HRT', 'IMC HRT', 'Rest SKT', 'IMC SKT' ]; my $row = 1; my ($cells,$formula,$ts2); for (<TABFILE>) { ... my $col = 0; for (@vals) { ... $worksheet->write($row, $col, $_); $col++; } $row++; } $worksheet->write(0,0, $headers1, $h_frmt); for(2,17,32,47) { $group_avg->write_col($_,0, \@cats) } $group_avg->write(0,1, 'Low-Hour VFR',$h_frmt); $group_avg->write(15,1, 'Low-Hour Instruments',$h_frmt); $group_avg->write(30,1, 'High-Hour Instruments',$h_frmt); $group_avg->write(45,1, 'All Groups',$h_frmt); $group_avg->write_row(1,5, ['Rest EMG', 'IMC EMG'], $h_frmt); for(1,16,31,46) { $group_avg->write_row($_,0, $headers2, $h_frmt) } for my $gr (0..3) { for my $avg(0..5) { for my $cond(0..$#cats) { my $ts = shift @{$ts2->[$gr][$avg][$cond]}; if( ($avg < 4) || ($gr == 0 && $ts >= 21) ) { my $sheet = $worksheet->get_name(); my $form = "=AVERAGE(${sheet}!" . join(",${sheet}!", @{$formula->[$gr][$avg][$cond]}) . ')'; $group_avg->write_formula( $cells->[$gr][$avg][$cond], $form ) +; } } } }
The massive amount I could figure from the (in my view sketchy) documentation is this:
my $file_name = 'test.xls'; my $xl = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit; +}) or die "Excel failed to load: Win32::OLE->new"; my $book = $xl->Workbooks->Add(); my @sheets = $xl->Worksheets(2); $sheets[0]->{Name} = 'all_avg'; $sheets[1]->{Name} = 'grp_avg'; $book->SaveAs($file_name)
I saw some things (e.g., Workbooks->Add()) on some nodes here, and an article in the perl journal, but the documentation never mentioned anything about these methods. Where can I find a list of them (preferably with some explanation/mention of calling convention)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: WriteExcel to OLE?
by cacharbe (Curate) on Jul 15, 2002 at 19:45 UTC | |
|
Re: WriteExcel to OLE?
by jsprat (Curate) on Jul 15, 2002 at 20:06 UTC | |
by dimmesdale (Friar) on Jul 15, 2002 at 21:31 UTC | |
by jsprat (Curate) on Jul 15, 2002 at 22:14 UTC |