Spreadsheet-WriteExcel-Simple-1.04/0000755000175200017520000000000010362700417015755 5ustar tonytonySpreadsheet-WriteExcel-Simple-1.04/t/0000755000175200017520000000000010362700417016220 5ustar tonytonySpreadsheet-WriteExcel-Simple-1.04/t/01.t0000644000175200017520000000210410164027101016612 0ustar tonytony#!/usr/bin/perl -w use strict; use Spreadsheet::WriteExcel::Simple; use Test::More; eval { require File::Temp; require Spreadsheet::ParseExcel; }; if ($@) { plan skip_all => 'Need File::Temp and Spreadsheet::ParseExcel to test'; } plan tests => 14; File::Temp->import(qw/tempfile tempdir/); my $dir1 = tempdir(CLEANUP => 1); for (1 .. 2) { my ($fh1, $name1) = tempfile(DIR => $dir1); # Write our our test file. my $ss = Spreadsheet::WriteExcel::Simple->new; $ss->write_bold_row([qw/foo bar baz/]); $ss->write_row([qw/1 fred 2001-01-01/]); $ss->save($name1); # Now read it back in my $oExcel = new Spreadsheet::ParseExcel; ok my $oBook = $oExcel->Parse($name1), "Parse $name1\n"; my $oWkS = $oBook->{Worksheet}[0]; is($oWkS->{Cells}[0][0]->Value, 'foo', 'heading: foo'); is($oWkS->{Cells}[0][1]->Value, 'bar', 'heading: bar'); is($oWkS->{Cells}[0][2]->Value, 'baz', 'heading: baz'); is($oWkS->{Cells}[1][0]->Value, '1', 'data: 1'); is($oWkS->{Cells}[1][1]->Value, 'fred', 'data: fred'); is($oWkS->{Cells}[1][2]->Value, '2001-01-01', 'data: date'); } Spreadsheet-WriteExcel-Simple-1.04/t/pod.t0000644000175200017520000000020110306404420017151 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-WriteExcel-Simple-1.04/t/pod-coverage.t0000644000175200017520000000024110306404420020746 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-WriteExcel-Simple-1.04/README0000644000175200017520000000515710362700241016640 0ustar tonytonyNAME Spreadsheet::WriteExcel::Simple - A simple single-sheet Excel document SYNOPSIS my $ss = Spreadsheet::WriteExcel::Simple->new; $ss->write_bold_row(\@headings); $ss->write_row(\@data); print $ss->data; # or $ss->save("filename.xls"); DESCRIPTION This provides an abstraction to the Spreadsheet::WriteExcel module for easier creation of simple single-sheet Excel documents. In its most basic form it provides two methods for writing data: write_row and write_bold_row which write the data supplied to the next row of the spreadsheet. However, you can also use $ss->book and $ss->sheet to get at the underlying workbook and worksheet from Spreadsheet::WriteExcel if you wish to manipulate these directly. METHODS new my $ss = Spreadsheet::WriteExcel::Simple->new; Create a new single-sheet Excel document. You should not supply this a filename or filehandle. The data is stored internally, and can be retrieved later through the 'data' method or saved using the 'save' method. write_row / write_bold_row $ss->write_bold_row(\@headings); $ss->write_row(\@data); These write the list of data into the next row of the spreadsheet. Caveat: An internal counter is kept as to which row is being written to, so if you mix these functions with direct writes of your own, these functions will continue where they left off, not where you have written to. data print $ss->data; This returns the data of the spreadsheet. If you're planning to print this to a web-browser, be sure to print an 'application/excel' header first. book / sheet my $workbook = $ss->book; my $worksheet = $ss->sheet; These return the underlying Spreadsheet::WriteExcel objects representing the workbook and worksheet respectively. If you find yourself making more that a trivial amount of use of these, you probably shouldn't be using this module, but using Spreadsheet::WriteExcel directly. save $ss->save("filename.xls"); Save the spreadsheet with the given filename. BUGS This can't yet handle dates in a sensible manner. AUTHOR Tony Bowden BUGS and QUERIES Please direct all correspondence regarding this module to: bug-Spreadsheet-WriteExcel-Simple@rt.cpan.org SEE ALSO Spreadsheet::WriteExcel. John McNamara has done a great job with this module. COPYRIGHT Copyright (C) 2001-2005 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. Spreadsheet-WriteExcel-Simple-1.04/Changes0000644000175200017520000000122310362700264017246 0ustar tonytonyRevision history for Perl extension Spreadsheet::WriteExcel::Simple. 1.04 Mon Jan 16 11:17:02 UTC 2006 - Doc tweaks 1.03 Sat Sep 3 20:36:47 UTC 2005 - Use binmode when save()-ing file (Ken Prows) 1.02 Dec 27 2004 - Reintegrate bizarrely unreleased 1.00 code 1.01 Dec 27 2004 - Added save() method [Terrence Brannon] 1.00 Tue Oct 15 2002 - Fixed tests to skip all if we don't have ParseExcel 0.03 Sun Sep 22 2002 - Moved row counter to object data so that multiple executions would run more smoothly. (thanks to Drew Taylor) 0.02 Sat Aug 11 2001 - added tests using Spreadsheet::ParseExcel 0.01 Tue Aug 7 2001 - original version Spreadsheet-WriteExcel-Simple-1.04/Simple.pm0000644000175200017520000000740510362700220017542 0ustar tonytonypackage Spreadsheet::WriteExcel::Simple; $VERSION = '1.04'; use strict; use Spreadsheet::WriteExcel 0.31; use IO::Scalar 1.126; =head1 NAME Spreadsheet::WriteExcel::Simple - A simple single-sheet Excel document =head1 SYNOPSIS my $ss = Spreadsheet::WriteExcel::Simple->new; $ss->write_bold_row(\@headings); $ss->write_row(\@data); print $ss->data; # or $ss->save("filename.xls"); =head1 DESCRIPTION This provides an abstraction to the L module for easier creation of simple single-sheet Excel documents. In its most basic form it provides two methods for writing data: write_row and write_bold_row which write the data supplied to the next row of the spreadsheet. However, you can also use $ss->book and $ss->sheet to get at the underlying workbook and worksheet from Spreadsheet::WriteExcel if you wish to manipulate these directly. =head1 METHODS =head2 new my $ss = Spreadsheet::WriteExcel::Simple->new; Create a new single-sheet Excel document. You should not supply this a filename or filehandle. The data is stored internally, and can be retrieved later through the 'data' method or saved using the 'save' method. =cut sub new { my $class = shift; my $self = bless {}, $class; my $fh = shift; # Store the workbook in a tied scalar filehandle $self->{book} = Spreadsheet::WriteExcel->new( IO::Scalar->new_tie(\($self->{content})) ); $self->{bold} = $self->book->addformat(); $self->{bold}->set_bold; $self->{sheet} = $self->book->addworksheet; $self->{_row} = 0; $self; } =head2 write_row / write_bold_row $ss->write_bold_row(\@headings); $ss->write_row(\@data); These write the list of data into the next row of the spreadsheet. Caveat: An internal counter is kept as to which row is being written to, so if you mix these functions with direct writes of your own, these functions will continue where they left off, not where you have written to. =cut sub write_row { my $self = shift; my $dataref = shift; my @data = map { defined $_ ? $_ : '' } @$dataref; my $fmt = shift || ''; my $col = 0; my $ws = $self->sheet; $ws->write($self->{_row}, $col++, $_, $fmt) foreach @data; $self->{_row}++; } sub write_bold_row { $_[0]->write_row($_[1], $_[0]->_bold) } =head2 data print $ss->data; This returns the data of the spreadsheet. If you're planning to print this to a web-browser, be sure to print an 'application/excel' header first. =cut sub data { my $self = shift; $self->book->close; return $self->{content}; } =head2 book / sheet my $workbook = $ss->book; my $worksheet = $ss->sheet; These return the underlying Spreadsheet::WriteExcel objects representing the workbook and worksheet respectively. If you find yourself making more that a trivial amount of use of these, you probably shouldn't be using this module, but using Spreadsheet::WriteExcel directly. =cut sub book { $_[0]->{book} } sub sheet { $_[0]->{sheet} } sub _bold { $_[0]->{bold} } =head2 save $ss->save("filename.xls"); Save the spreadsheet with the given filename. =cut sub save { my $self = shift; my $name = shift or die 'save() needs a file name'; open my $file, ">$name" or die "Could not open $name for writing: $!"; binmode $file; print $file $self->data; close $file; } =head1 BUGS This can't yet handle dates in a sensible manner. =head1 AUTHOR Tony Bowden =head1 BUGS and QUERIES Please direct all correspondence regarding this module to: bug-Spreadsheet-WriteExcel-Simple@rt.cpan.org =head1 SEE ALSO L. John McNamara has done a great job with this module. =head1 COPYRIGHT Copyright (C) 2001-2005 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. =cut 1; Spreadsheet-WriteExcel-Simple-1.04/Makefile.PL0000644000175200017520000000116110306404442017723 0ustar tonytonyuse ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( 'NAME' => 'Spreadsheet::WriteExcel::Simple', 'VERSION_FROM' => 'Simple.pm', # finds $VERSION 'PREREQ_PM' => { 'Spreadsheet::WriteExcel' => 0.31, 'IO::Scalar' => 1.126, 'Test::More' => 0.04, }, ( $] >= 5.005 ? ## Add these new keywords supported since 5.005 ( ABSTRACT_FROM => 'Simple.pm', # retrieve abstract from module AUTHOR => 'Tony Bowden ' ) : () ), ); Spreadsheet-WriteExcel-Simple-1.04/META.yml0000644000175200017520000000066410362700416017233 0ustar tonytony# http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: Spreadsheet-WriteExcel-Simple version: 1.04 version_from: Simple.pm installdirs: site requires: IO::Scalar: 1.126 Spreadsheet::WriteExcel: 0.31 Test::More: 0.04 distribution_type: module generated_by: ExtUtils::MakeMaker version 6.17 Spreadsheet-WriteExcel-Simple-1.04/MANIFEST0000644000175200017520000000015410362700376017112 0ustar tonytonyChanges Makefile.PL MANIFEST This list of files META.yml README Simple.pm t/01.t t/pod-coverage.t t/pod.t