r1204 - in packages: . libspreadsheet-parseexcel-simple-perl libspreadsheet-parseexcel-simple-perl/branches libspreadsheet-parseexcel-simple-perl/branches/upstream libspreadsheet-parseexcel-simple-perl/branches/upstream/current libspreadsheet-parseexcel-simple-perl/branches/upstream/current/t
Gunnar Wolf
gwolf@costa.debian.org
Tue Jul 5 10:08:12 UTC 2005
Author: gwolf
Date: 2005-07-05 10:08:12 +0000 (Tue, 05 Jul 2005)
New Revision: 1204
Added:
packages/libspreadsheet-parseexcel-simple-perl/
packages/libspreadsheet-parseexcel-simple-perl/branches/
packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/
packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/
packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/Changes
packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/MANIFEST
packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/META.yml
packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/Makefile.PL
packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/README
packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/Simple.pm
packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/t/
packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/t/01.t
packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/t/02.t
packages/libspreadsheet-parseexcel-simple-perl/tags/
Log:
[svn-inject] Installing original source of libspreadsheet-parseexcel-simple-perl
Added: packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/Changes
===================================================================
--- packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/Changes 2005-07-04 16:34:57 UTC (rev 1203)
+++ packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/Changes 2005-07-05 10:08:12 UTC (rev 1204)
@@ -0,0 +1,21 @@
+Revision history for Perl extension Spreadsheet::ParseExcel::Simple.
+
+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
+
Added: packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/MANIFEST
===================================================================
--- packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/MANIFEST 2005-07-04 16:34:57 UTC (rev 1203)
+++ packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/MANIFEST 2005-07-05 10:08:12 UTC (rev 1204)
@@ -0,0 +1,8 @@
+Changes
+MANIFEST
+Makefile.PL
+README
+Simple.pm
+t/01.t
+t/02.t
+META.yml Module meta-data (added by MakeMaker)
Added: packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/META.yml
===================================================================
--- packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/META.yml 2005-07-04 16:34:57 UTC (rev 1203)
+++ packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/META.yml 2005-07-05 10:08:12 UTC (rev 1204)
@@ -0,0 +1,12 @@
+# 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.02
+version_from: Simple.pm
+installdirs: site
+requires:
+ Spreadsheet::ParseExcel: 0.18
+ Test::More: 0.01
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.21
Added: packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/Makefile.PL
===================================================================
--- packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/Makefile.PL 2005-07-04 16:34:57 UTC (rev 1203)
+++ packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/Makefile.PL 2005-07-05 10:08:12 UTC (rev 1204)
@@ -0,0 +1,13 @@
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+ 'NAME' => 'Spreadsheet::ParseExcel::Simple',
+ 'VERSION_FROM' => 'Simple.pm', # finds $VERSION
+ 'PREREQ_PM' => {
+ 'Spreadsheet::ParseExcel' => 0.18,
+ 'Test::More' => 0.01,
+ },
+ ($] >= 5.005 ?
+ (ABSTRACT_FROM => 'Simple.pm', # retrieve abstract from module
+ AUTHOR => 'Tony Bowden <kasei@tmtm.com>') : ()),
+);
Added: packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/README
===================================================================
--- packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/README 2005-07-04 16:34:57 UTC (rev 1203)
+++ packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/README 2005-07-05 10:08:12 UTC (rev 1204)
@@ -0,0 +1,58 @@
+NAME
+ 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.
+
+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.
+
+ 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.
+
+AUTHOR
+ Tony Bowden, <kasei@tmtm.com>.
+
+SEE ALSO
+ Spreadsheet::ParseExcel.
+
+COPYRIGHT
+ Copyright (C) 2001 Tony Bowden. All rights reserved.
+
+ This module is free software; you can redistribute it and/or modify it
+ under the same terms as Perl itself.
+
Added: packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/Simple.pm
===================================================================
--- packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/Simple.pm 2005-07-04 16:34:57 UTC (rev 1203)
+++ packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/Simple.pm 2005-07-05 10:08:12 UTC (rev 1204)
@@ -0,0 +1,118 @@
+package Spreadsheet::ParseExcel::Simple;
+
+use strict;
+use Spreadsheet::ParseExcel;
+use vars qw/$VERSION/;
+$VERSION = '1.02';
+
+=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 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 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.
+
+=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-2004 Tony Bowden. All rights reserved.
+
+This module is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=head1 SEE ALSO
+
+L<Spreadsheet::ParseExcel>.
+
+=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 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;
+
Added: packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/t/01.t
===================================================================
--- packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/t/01.t 2005-07-04 16:34:57 UTC (rev 1203)
+++ packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/t/01.t 2005-07-05 10:08:12 UTC (rev 1204)
@@ -0,0 +1,59 @@
+#!/usr/bin/perl -w
+
+use strict;
+use Spreadsheet::ParseExcel::Simple;
+use Test::More tests => 11;
+
+eval {
+ require File::Temp;
+ require Spreadsheet::WriteExcel::Simple;
+};
+
+if ($@) {
+ ok(1, "Need File::Temp and Spreadsheet::WriteExcel::Simple");
+ ok(1, " for sensible testing.");
+ ok(1, " - skipping tests") for (1 .. 9);
+} else {
+ 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);
+ print $fh1 $ss->data;
+ close $fh1;
+
+ # 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;
+ ok eq_array(\@fetch1, \@row1), "Header OK";
+
+ ok $sheet->has_data, "We still have data to read";
+ my @fetch2 = $sheet->next_row;
+ ok eq_array(\@fetch2, \@row2), "Row 2";
+
+ ok $sheet->has_data, "We still have data to read";
+ my @fetch3 = $sheet->next_row;
+ ok eq_array(\@fetch3, \@row3), "Row 3 (blank)";
+
+ ok $sheet->has_data, "We still have data to read";
+ my @fetch4 = $sheet->next_row;
+ ok eq_array(\@fetch4, \@row4), "Row 4";
+
+ ok !$sheet->has_data, "No more data to read";
+ ok !$sheet->next_row, "So, can't read any";
+}
Added: packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/t/02.t
===================================================================
--- packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/t/02.t 2005-07-04 16:34:57 UTC (rev 1203)
+++ packages/libspreadsheet-parseexcel-simple-perl/branches/upstream/current/t/02.t 2005-07-05 10:08:12 UTC (rev 1204)
@@ -0,0 +1,29 @@
+#!/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::WriteExcel;
+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";
+}
More information about the Pkg-perl-cvs-commits
mailing list