/[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 1216 by dpavlin, Mon Aug 4 19:35:23 2008 UTC revision 1217 by dpavlin, Tue Jun 9 18:38:36 2009 UTC
# Line 11  use base qw/WebPAC::Common/; Line 11  use base qw/WebPAC::Common/;
11    
12  WebPAC::Input::Excel - support for Microsoft Excel and compatibile files  WebPAC::Input::Excel - support for Microsoft Excel and compatibile files
13    
 =head1 VERSION  
   
 Version 0.04  
   
14  =cut  =cut
15    
16  our $VERSION = '0.04';  our $VERSION = '0.05';
17    
18    
19  =head1 SYNOPSIS  =head1 SYNOPSIS
# Line 39  Returns handle to database and size Line 35  Returns handle to database and size
35    }    }
36    
37  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
38  file to use. If not specified, it will use first worksheet in file.  file to use. If not specified, name of input is used. If none of those
39    methods returned sheet, first worksheet in file is used instead.
40    
41  C<from> and C<to> specify row numbers to start and finish import.  C<from> and C<to> specify row numbers to start and finish import.
42    
# Line 57  sub new { Line 54  sub new {
54          my $workbook = Spreadsheet::ParseExcel::Workbook->Parse($self->{path});          my $workbook = Spreadsheet::ParseExcel::Workbook->Parse($self->{path});
55    
56          my $sheet;          my $sheet;
57          my $wanted_worksheet;          my $wanted_worksheet = $self->{worksheet} || $self->{name};
58    
59          if ($wanted_worksheet = $self->{worksheet}) {          if ($wanted_worksheet) {
60                  my $name;                  my $name;
61                  do {                  do {
62                          $sheet = shift @{ $workbook->{Worksheet} };                          $sheet = shift @{ $workbook->{Worksheet} };
# Line 68  sub new { Line 65  sub new {
65                          $name =~ s/\s\s+/ /g;                          $name =~ s/\s\s+/ /g;
66                  } until ($name =~ m/^\s*\Q$wanted_worksheet\E\s*$/i);                  } until ($name =~ m/^\s*\Q$wanted_worksheet\E\s*$/i);
67    
         } else {  
   
                 $sheet = shift @{ $workbook->{Worksheet} };  
           
68          }          }
69    
70            $sheet ||= shift @{ $workbook->{Worksheet} };
71    
72          $self->{sheet} = $sheet;          $self->{sheet} = $sheet;
73    
74          $self->{from} ||= $sheet->{MinRow};          $self->{from} ||= $sheet->{MinRow};
# Line 144  sub size { Line 139  sub size {
139    
140  sub default_encoding { 'UTF-16' }  sub default_encoding { 'UTF-16' }
141    
142    our @labels;
143    our @names;
144    
145    sub normalize {
146            my ($self,$mfn) = @_;
147    
148            my $log = $self->_get_logger();
149    
150            my $sheet = $self->{sheet};
151    
152            if ( ! @labels ) {
153                    push @labels, $sheet->{Cells}->[0]->[$_]->{_Value}
154                    foreach ( $sheet->{MinCol} ... $sheet->{MaxCol} )
155                    ;
156                    @names = map { s{\W+}{_}; $_ } @labels;
157                    $log->loginfo("column labels:", @labels, @names);
158            }
159    
160            my $row = $self->{from} + $mfn - 1;
161    
162            
163    }
164    
165  =head1 AUTHOR  =head1 AUTHOR
166    
167  Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>  Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>

Legend:
Removed from v.1216  
changed lines
  Added in v.1217

  ViewVC Help
Powered by ViewVC 1.1.26