dimmesdale has asked for the wisdom of the Perl Monks concerning the following question:
I was getting unblessed reference errors, though I think I *may* be past that now. Now it says 'Unable to set LineStyle property of the Border class', then it says ERROR exception occurred (hex reference) in PROPERTYPUT "LineSTyle".
Also, the general page itself is not being laid out as I want (the names aren't there--for the worksheets, which themselves aren't all there). Here's the code stripped down.
#!/usr/bin/perl -w use strict; use Spreadsheet::WriteExcel::Utility; use Win32::OLE qw(in valof with); use Win32::OLE::Const 'Microsoft Excel'; use Win32::OLE::NLS qw(:DEFAULT :LANG :SUBLANG); $Win32::OLE::Warn = 3; my $file = 'test.txt'; open (TABFILE,$file) or die "$file: $!"; # Create a new Excel workbook my $file_name = 'test.xls'; my $xl = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;}) or die "error message"; my $book = $xl->Workbooks->Add(); my $sheet1 = $xl->Worksheets->Add(); my $sheet2 = $xl->Worksheets->Add(); $sheet1->{Name} = 'all_avg'; $sheet2->{Name} = 'grp_avg'; #$sheet2->Activate(); $book->SaveAs($file_name); my @edges = qw (xlEdgeBottom xlEdgeLeft xlEdgeRight xlEdgeTop xlInsideHorizontal xlInsideVertical); my @ranges = qw (B1 A2:G2 B16 A17:E17 B31 A32:E32 B46 A47:E47); for my $range (@ranges) { for my $edge (@edges) { with (my $Borders = $sheet2->Range($range)->Borders(eval($edge)), LineStyle =>xlContinuous, Weight => xlThin , ColorIndex => 1); } } for my $edge (@edges) { with (my $Borders = $sheet1->Range('A1:G1')->Borders(eval($edge)), LineStyle =>xlContinuous, Weight => xlThin , ColorIndex => 1); } $book->SaveAs($file_name); for (<TABFILE>) { $sheet1->Range(x1_rowcol_to_cell($row,$col))->{Value} = $_; } $book->SaveAs($file_name); $sheet1->Range('A1:G1')->{Value} = @$headers1; for(2,17,32,47) { $sheet2->Range(x1_rowcol_to_cell($_,0))->{Value} = @cats } for(0,15,30,45) { $sheet2->Range(x1_rowcol_to_cell($_,1))->{Value} = @$headers3; } for(1,16,31,46) { $sheet2->Range(x1_rowcol_to_cell($_,0))->{Value} = @$headers2; } $sheet2->Range(x1_rowcol_to_cell(1,5))->{Value} = ('Rest EMG', 'IMC EMG'); ## inside several for loops $sheet2->Range($cells->[$gr][$avg][$cond])->{Value} = $form; $book->SaveAs($file_name);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Win32::OLE Woes
by jsprat (Curate) on Jul 16, 2002 at 15:01 UTC | |
by dimmesdale (Friar) on Jul 16, 2002 at 15:17 UTC |