--- trunk/lib/WebPAC/Input/Excel.pm 2006/05/18 13:49:08 521 +++ trunk/lib/WebPAC/Input/Excel.pm 2006/05/21 19:38:56 524 @@ -13,11 +13,11 @@ =head1 VERSION -Version 0.01 +Version 0.02 =cut -our $VERSION = '0.01'; +our $VERSION = '0.02'; =head1 SYNOPSIS @@ -37,14 +37,19 @@ my ($db,$size) = $open_db( path => '/path/to/workbook.xls' worksheet => 'name of sheet', + from => 42, + to => 9999, } C is case and white-space insensitive name of worksheet in Excel file to use. If not specified, it will use first worksheet in file. +C and C specify row numbers to start and finish import. + =cut my $sheet; +my ($from,$to); sub open_db { my $self = shift; @@ -63,6 +68,7 @@ my $name; do { $sheet = shift @{ $workbook->{Worksheet} }; + $log->logdie("can't find sheet '$wanted_worksheet' in $arg->{path}\n") unless (defined($sheet)); $name = $sheet->{Name}; $name =~ s/\s\s+/ /g; } until ($name =~ m/^\s*\Q$wanted_worksheet\E\s*$/i); @@ -73,7 +79,10 @@ } - $size = $sheet->{MaxRow} - $sheet->{MinRow}; + $from = $arg->{from} || $sheet->{MinRow}; + $to = $arg->{to} || $sheet->{MaxRow}; + + $size = $to - $from; $log->warn("opening Excel file '$arg->{path}', using ", $wanted_worksheet ? '' : 'first ', @@ -105,7 +114,7 @@ my $rec; - my $row = $sheet->{MinRow} + $mfn - 1; + my $row = $from + $mfn - 1; $log->debug("fetch_rec( $mfn ) row: $row cols: ",$sheet->{MinCol}," - ",$sheet->{MaxCol});