in reply to excelPerl V0.08
Proposed cleanup for the dirt mentioned in ExcelPerl.pm/getNextRow:
my $rowData = $sheet->Range("A$row:IV$row")->{Value}; # dirty
Idea: A range has a method address to stringify itself, giving the string one needs in the constructor à la range("A1:X1").
Also add maxCol to @ObjInterfaceMethod to initially create it.my $bottomRight = (split (/:/, $self->worksheet->UsedRange->addres +s(0,0)))[-1]; my ($colNameMax, $rowNumMax) = $bottomRight =~ /^([A-Z]+)(\d+)/; $self->lastRow( $rowNumMax ); $self->maxCol( $colNameMax );
But we also have to change the construction of the list to iterate over in the foreach following:my $rowData = $sheet->Range("A$row:" . $self->maxCol . $row)->{Value};
because $rowdata is only a scalar when maxCol eq 'A'.foreach my $value (ref $rowData ? reverse @{ $rowData->[0] } : $rowDat +a) {
We can take an additional step (now in excelPerl.pl) and compile (eval) the $perCode only once:
my $fn = eval "sub { my \@F = \@_; no warnings 'uninitialized'; $perlCode }"; die $@ if $@;
Maybe we want the no warnings as shown in that tight scope, since our first change made it more likely that an index out of range for @F will be tried to access in the $perlCode.
The former eval part in the while - getNextRow changes to
$fn->(@F);with that.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: excelPerl V0.08
by strat (Canon) on Jan 17, 2007 at 09:47 UTC |