Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: excelPerl V0.08

by pKai (Priest)
on Jan 12, 2007 at 14:43 UTC ( [id://594395]=note: print w/replies, xml ) Need Help??


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").

  1. Expand open by not only saving the lastRow, but also the maxCol:
    my $bottomRight = (split (/:/, $self->worksheet->UsedRange->addres +s(0,0)))[-1]; my ($colNameMax, $rowNumMax) = $bottomRight =~ /^([A-Z]+)(\d+)/; $self->lastRow( $rowNumMax ); $self->maxCol( $colNameMax );
    Also add maxCol to @ObjInterfaceMethod to initially create it.
  2. Now you can do the following in getNextRow:
    my $rowData = $sheet->Range("A$row:" . $self->maxCol . $row)->{Value};
    But we also have to change the construction of the list to iterate over in the foreach following:
    foreach my $value (ref $rowData ? reverse @{ $rowData->[0] } : $rowDat +a) {
    because $rowdata is only a scalar when maxCol eq '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

    @pKai: thank you for these good ideas; I added them in V0.09

    Best regards,
    perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://594395]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-25 23:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found