Spreadsheet-ParseExcel-Simple-1.04/0040755000176300017630000000000010523335741015750 5ustar tonytonySpreadsheet-ParseExcel-Simple-1.04/README0100644000176300017630000000471010306424317016624 0ustar tonytonyNAME Spreadsheet::ParseExcel::Simple - A simple interface to Excel data SYNOPSIS my $xls = Spreadsheet::ParseExcel::Simple->read('spreadsheet.xls'); foreach my $sheet ($xls->sheets) { while ($sheet->has_data) { my @data = $sheet->next_row; } } DESCRIPTION This provides an abstraction to the Spreadsheet::ParseExcel module for simple reading of values. You simply loop over the sheets, and fetch rows to arrays. For anything more complex, you probably want to use Spreadsheet::ParseExcel directly. BOOK METHODS read my $xls = Spreadsheet::ParseExcel::Simple->read('spreadsheet.xls'); This opens the spreadsheet specified for you. Returns undef if we cannot read the book. sheets @sheets = $xls->sheets; Each spreadsheet can contain one or more worksheets. This fetches them all back. You can then iterate over them, or jump straight to the one you wish to play with. book my $book = $xls->book; The Spreadsheet::ParseExcel object we are working with. You can use this if you need to manipulate it in ways that this interface doesn't allow. SHEET METHODS These methods can be called on each sheet returned from $xls->sheets: has_data if ($sheet->has_data) { ... } This lets us know if there are more rows in this sheet that we haven't read yet. This allows us to differentiate between an empty row, and the end of the sheet. next_row my @data = $sheet->next_row; Fetch the next row of data back. sheet my $obj = $sheet->sheet; The underlying Spreadsheet::ParseExcel object for the worksheet. You can use this if you need to manipulate it in ways that this interface doesn't allow (e.g. asking it for the sheet's name). AUTHOR Tony Bowden BUGS and QUERIES Please direct all correspondence regarding this module to: bug-Spreadsheet-ParseExcel-Simple@rt.cpan.org COPYRIGHT AND LICENSE Copyright (C) 2001-2005 Tony Bowden. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. SEE ALSO Spreadsheet::ParseExcel. Spreadsheet-ParseExcel-Simple-1.04/t/0040755000176300017630000000000010523335741016213 5ustar tonytonySpreadsheet-ParseExcel-Simple-1.04/t/pod.t0100644000176300017630000000020110306421713017142 0ustar tonytonyuse Test::More; eval "use Test::Pod 1.00"; plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; all_pod_files_ok(); Spreadsheet-ParseExcel-Simple-1.04/t/01.t0100644000176300017630000000275610306424227016624 0ustar tonytony#!/usr/bin/perl -w use strict; use Spreadsheet::ParseExcel::Simple; use Test::More; BEGIN { eval "use File::Temp; use Spreadsheet::WriteExcel::Simple 1.03"; plan $@ ? (skip_all => 'tests need Spreadsheet::WriteExcel::Simple 1.03 + File::Temp') : (tests => 11); } File::Temp->import(qw/tempfile tempdir/); my $dir1 = tempdir(CLEANUP => 1); my ($fh1, $name1) = tempfile(DIR => $dir1); my @row1 = qw/foo bar baz/; my @row2 = qw/1 fred 2001-01-01/; my @row3 = (); my @row4 = (2, undef, "2001-03-01"); # Write our our test file. my $ss = Spreadsheet::WriteExcel::Simple->new; $ss->write_bold_row(\@row1); $ss->write_row(\@row2); $ss->write_row(\@row3); $ss->write_row(\@row4); $ss->save($name1); # Now read it back in my $xls = Spreadsheet::ParseExcel::Simple->read($name1); my @sheets = $xls->sheets; is scalar @sheets, 1, "We have one sheet"; my $sheet = $sheets[0]; ok $sheet->has_data, "We have data to read"; my @fetch1 = $sheet->next_row; is_deeply \@fetch1, \@row1, "Header OK"; ok $sheet->has_data, "We still have data to read"; my @fetch2 = $sheet->next_row; is_deeply \@fetch2, \@row2, "Row 2"; ok $sheet->has_data, "We still have data to read"; my @fetch3 = $sheet->next_row; is_deeply \@fetch3, \@row3, "Row 3 (blank)"; ok $sheet->has_data, "We still have data to read"; my @fetch4 = $sheet->next_row; local $row4[1] = ""; # undefs come back as empty string is_deeply \@fetch4, \@row4, "Row 4"; ok !$sheet->has_data, "No more data to read"; ok !$sheet->next_row, "So, can't read any"; Spreadsheet-ParseExcel-Simple-1.04/t/02.t0100644000176300017630000000123710523335630016616 0ustar tonytony#!/usr/bin/perl -w use Test::More; eval { require Spreadsheet::WriteExcel }; plan skip_all => "Need Spreadsheet::WriteExcel for this test" if $@; plan tests => 2; use strict; use Spreadsheet::ParseExcel::Simple; my $workbook = Spreadsheet::WriteExcel->new("test.xls"); my $worksheet1 = $workbook->add_worksheet(); my $worksheet2 = $workbook->add_worksheet(); $worksheet1->write('A1', 'Hello'); # 1 row $worksheet2->write('A1', 'Hello'); # 2 rows $worksheet2->write('A2', 'Hello'); $workbook->close(); my $xls = Spreadsheet::ParseExcel::Simple->read('test.xls'); for my $sheet ($xls->sheets) { ok $sheet->has_data, "Sheet $sheet->{sheet}->{Name} has data"; } Spreadsheet-ParseExcel-Simple-1.04/t/pod-coverage.t0100644000176300017630000000024110306421713020737 0ustar tonytonyuse Test::More; eval "use Test::Pod::Coverage 1.00"; plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage" if $@; all_pod_coverage_ok(); Spreadsheet-ParseExcel-Simple-1.04/MANIFEST0100644000176300017630000000022710306423261017071 0ustar tonytonyChanges lib/Spreadsheet/ParseExcel/Simple.pm Makefile.PL MANIFEST This list of files META.yml README t/01.t t/02.t t/pod-coverage.t t/pod.t test.xls Spreadsheet-ParseExcel-Simple-1.04/META.yml0100644000176300017630000000064610523335740017223 0ustar tonytony# http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: Spreadsheet-ParseExcel-Simple version: 1.04 version_from: lib/Spreadsheet/ParseExcel/Simple.pm installdirs: site requires: Spreadsheet::ParseExcel: 0.18 Test::More: 0.01 distribution_type: module generated_by: ExtUtils::MakeMaker version 6.21 Spreadsheet-ParseExcel-Simple-1.04/Changes0100644000176300017630000000133710523335714017244 0ustar tonytonyRevision history for Perl extension Spreadsheet::ParseExcel::Simple. 1.04 Sun Nov 5 10:23:43 GMT 2006 - Allow t/02 to skip gracefully when missing Spreadsheet::WriteExcel 1.03 Sat Sep 3 22:32:22 UTC 2005 - Document accessing the underlying Spreadsheet::ParseExcel objects - Tidy tests 1.02 Wed Mar 23 2005 - handle single row worksheets (Josh Rosenbaum, John McNamara) 1.01 Thu Dec 12 2002 - return undef if can't read the document (thanks to Marty Pauley and Adrian Howard) 1.00 Wed Aug 14 2002 - tweaked tests to work better when you don't have Spreadsheet::WriteExcel 0.02 Thu Sep 13 2001 - handle empty worksheets better (Thanks to Mark Thomas) 0.01 Sat Sep 1 2001 - original version Spreadsheet-ParseExcel-Simple-1.04/Makefile.PL0100644000176300017630000000055110306422422017710 0ustar tonytonyuse ExtUtils::MakeMaker; WriteMakefile( NAME => 'Spreadsheet::ParseExcel::Simple', AUTHOR => 'Tony Bowden ', VERSION_FROM => 'lib/Spreadsheet/ParseExcel/Simple.pm', ABSTRACT_FROM => 'lib/Spreadsheet/ParseExcel/Simple.pm', PREREQ_PM => { 'Spreadsheet::ParseExcel' => 0.18, 'Test::More' => 0.01, }, ); Spreadsheet-ParseExcel-Simple-1.04/lib/0040755000176300017630000000000010523335741016516 5ustar tonytonySpreadsheet-ParseExcel-Simple-1.04/lib/Spreadsheet/0040755000176300017630000000000010523335741020765 5ustar tonytonySpreadsheet-ParseExcel-Simple-1.04/lib/Spreadsheet/ParseExcel/0040755000176300017630000000000010523335741023020 5ustar tonytonySpreadsheet-ParseExcel-Simple-1.04/lib/Spreadsheet/ParseExcel/Simple.pm0100644000176300017630000000625410523335645024616 0ustar tonytonypackage Spreadsheet::ParseExcel::Simple; $VERSION = '1.04'; use strict; use Spreadsheet::ParseExcel; =head1 NAME Spreadsheet::ParseExcel::Simple - A simple interface to Excel data =head1 SYNOPSIS my $xls = Spreadsheet::ParseExcel::Simple->read('spreadsheet.xls'); foreach my $sheet ($xls->sheets) { while ($sheet->has_data) { my @data = $sheet->next_row; } } =head1 DESCRIPTION This provides an abstraction to the Spreadsheet::ParseExcel module for simple reading of values. You simply loop over the sheets, and fetch rows to arrays. For anything more complex, you probably want to use Spreadsheet::ParseExcel directly. =head1 BOOK METHODS =head2 read my $xls = Spreadsheet::ParseExcel::Simple->read('spreadsheet.xls'); This opens the spreadsheet specified for you. Returns undef if we cannot read the book. =head2 sheets @sheets = $xls->sheets; Each spreadsheet can contain one or more worksheets. This fetches them all back. You can then iterate over them, or jump straight to the one you wish to play with. =head2 book my $book = $xls->book; The Spreadsheet::ParseExcel object we are working with. You can use this if you need to manipulate it in ways that this interface doesn't allow. =head1 SHEET METHODS These methods can be called on each sheet returned from $xls->sheets: =head2 has_data if ($sheet->has_data) { ... } This lets us know if there are more rows in this sheet that we haven't read yet. This allows us to differentiate between an empty row, and the end of the sheet. =head2 next_row my @data = $sheet->next_row; Fetch the next row of data back. =head2 sheet my $obj = $sheet->sheet; The underlying Spreadsheet::ParseExcel object for the worksheet. You can use this if you need to manipulate it in ways that this interface doesn't allow (e.g. asking it for the sheet's name). =head1 AUTHOR Tony Bowden =head1 BUGS and QUERIES Please direct all correspondence regarding this module to: bug-Spreadsheet-ParseExcel-Simple@rt.cpan.org =head1 COPYRIGHT AND LICENSE Copyright (C) 2001-2005 Tony Bowden. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. =head1 SEE ALSO L. =cut sub read { my $class = shift; my $book = Spreadsheet::ParseExcel->new->Parse(shift) or return; bless { book => $book }, $class; } sub book { shift->{book} } sub sheets { map Spreadsheet::ParseExcel::Simple::_Sheet->new($_), @{shift->{book}->{Worksheet}}; } package Spreadsheet::ParseExcel::Simple::_Sheet; sub new { my $class = shift; my $sheet = shift; bless { sheet => $sheet, row => $sheet->{MinRow} || 0, }, $class; } sub sheet { shift->{sheet} } sub has_data { my $self = shift; defined $self->{sheet}->{MaxRow} and ($self->{row} <= $self->{sheet}->{MaxRow}); } sub next_row { map { $_ ? $_->Value : "" } @{$_[0]->{sheet}->{Cells}[$_[0]->{row}++]}; } 1; Spreadsheet-ParseExcel-Simple-1.04/test.xls0100644000176300017630000001300010523335723017446 0ustar tonytonyࡱ>   AB=%r8X"1Arial1Arial1Arial1Arial1Arial1 Arial                  83ffff̙̙3f3fff3f3f33333f33333Sheet1Sheet2Hello  A*+&?'?(?)?"dXX?? >@  A*+&?'?(?)?"dXX??  >@ Root EntryBook