/[webpac2]/trunk/lib/WebPAC/Input/Excel.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/WebPAC/Input/Excel.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 521 by dpavlin, Thu May 18 13:49:08 2006 UTC revision 524 by dpavlin, Sun May 21 19:38:56 2006 UTC
# Line 13  WebPAC::Input::Excel - support for Micro Line 13  WebPAC::Input::Excel - support for Micro
13    
14  =head1 VERSION  =head1 VERSION
15    
16  Version 0.01  Version 0.02
17    
18  =cut  =cut
19    
20  our $VERSION = '0.01';  our $VERSION = '0.02';
21    
22    
23  =head1 SYNOPSIS  =head1 SYNOPSIS
# Line 37  Returns handle to database and size Line 37  Returns handle to database and size
37    my ($db,$size) = $open_db(    my ($db,$size) = $open_db(
38          path => '/path/to/workbook.xls'          path => '/path/to/workbook.xls'
39          worksheet => 'name of sheet',          worksheet => 'name of sheet',
40            from => 42,
41            to => 9999,
42    }    }
43    
44  C<worksheet> is case and white-space insensitive name of worksheet in Excel  C<worksheet> is case and white-space insensitive name of worksheet in Excel
45  file to use. If not specified, it will use first worksheet in file.  file to use. If not specified, it will use first worksheet in file.
46    
47    C<from> and C<to> specify row numbers to start and finish import.
48    
49  =cut  =cut
50    
51  my $sheet;  my $sheet;
52    my ($from,$to);
53    
54  sub open_db {  sub open_db {
55          my $self = shift;          my $self = shift;
# Line 63  sub open_db { Line 68  sub open_db {
68                  my $name;                  my $name;
69                  do {                  do {
70                          $sheet = shift @{ $workbook->{Worksheet} };                          $sheet = shift @{ $workbook->{Worksheet} };
71                            $log->logdie("can't find sheet '$wanted_worksheet' in $arg->{path}\n") unless (defined($sheet));
72                          $name = $sheet->{Name};                          $name = $sheet->{Name};
73                          $name =~ s/\s\s+/ /g;                          $name =~ s/\s\s+/ /g;
74                  } until ($name =~ m/^\s*\Q$wanted_worksheet\E\s*$/i);                  } until ($name =~ m/^\s*\Q$wanted_worksheet\E\s*$/i);
# Line 73  sub open_db { Line 79  sub open_db {
79                    
80          }          }
81    
82          $size = $sheet->{MaxRow} - $sheet->{MinRow};          $from = $arg->{from} || $sheet->{MinRow};
83            $to = $arg->{to} || $sheet->{MaxRow};
84    
85            $size = $to - $from;
86    
87          $log->warn("opening Excel file '$arg->{path}', using ",          $log->warn("opening Excel file '$arg->{path}', using ",
88                  $wanted_worksheet ? '' : 'first ',                  $wanted_worksheet ? '' : 'first ',
# Line 105  sub fetch_rec { Line 114  sub fetch_rec {
114    
115          my $rec;          my $rec;
116    
117          my $row = $sheet->{MinRow} + $mfn - 1;          my $row = $from + $mfn - 1;
118    
119          $log->debug("fetch_rec( $mfn ) row: $row cols: ",$sheet->{MinCol}," - ",$sheet->{MaxCol});          $log->debug("fetch_rec( $mfn ) row: $row cols: ",$sheet->{MinCol}," - ",$sheet->{MaxCol});
120    

Legend:
Removed from v.521  
changed lines
  Added in v.524

  ViewVC Help
Powered by ViewVC 1.1.26