Skip Menu |

This queue is for tickets about the Spreadsheet-ParseExcel-Simple CPAN distribution.

Report information
The Basics
Id: 9178
Status: new
Priority: 0/
Queue: Spreadsheet-ParseExcel-Simple

People
Owner: Nobody in particular
Requestors: bill [...] tribley.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



From: "Bill Tribley" <bill [...] tribley.org>
To: <kasei [...] tmtm.com>
Subject: Spreadsheet::ParseExcel::Simple Suggested Change
Date: Wed, 19 May 2004 21:37:46 -0500
Hi Tony, Thank you for writing this Simple interface. I have been using it for a year and liking it a lot! In the last 6 months I have been working with Japanese spreadsheets. As you know, the original authors of the Spreadsheet stuff are Japanese, they have good support for Asian languages. But, the Simple module as it is now does not permit passing the FormatObject which permits processing different character sets. I have made a trivial modification in Spreadsheet::ParseExcel::Simple which permits this. Would it be possible to include it in the distro? Here is a diff: root@mail dir[/usr/local/lib/perl5/site_perl/5.8.3/Spreadsheet/ParseExcel] $ diff Simple.pm Simple.pm.orig 35,39c35 < # Simplest Case < my $xls = Spreadsheet::ParseExcel::Simple->read('spreadsheet.xls'); # Default Charset < < # Case of using Character Formats < use Spreadsheet::ParseExcel::FmtJapan; # Many others available --- Show quoted text
> my $xls = Spreadsheet::ParseExcel::Simple->read('spreadsheet.xls');
41,45c37,38 < my $oFmtJ = Spreadsheet::ParseExcel::FmtJapan->new(Code => 'sjis'); # euc, jis, etc. < my $xls = Spreadsheet::ParseExcel::Simple->read('spreadsheet.xls',$oFmtJ); < < This opens the spreadsheet specified for you. $formatObject is optional, used for < non-default characters sets. Returns undef if we cannot read the book. --- Show quoted text
> This opens the spreadsheet specified for you. Returns undef if we cannot > read the book.
87,94c80,81 < my ($class,$sheetPath,$charFormatObject) = @_; < my $book; < if (defined $charFormatObject){ < $book = Spreadsheet::ParseExcel->new->Parse($sheetPath,$charFormatObject) or return; < } < else { < $book = Spreadsheet::ParseExcel->new->Parse($sheetPath) or return; < } --- Show quoted text
> my $class = shift; > my $book = Spreadsheet::ParseExcel->new->Parse(shift) or return;
Here is the first 100 lines of the changed module: package Spreadsheet::ParseExcel::Simple; use strict; use Spreadsheet::ParseExcel; use vars qw/$VERSION/; $VERSION = '1.01'; =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 # Simplest Case my $xls = Spreadsheet::ParseExcel::Simple->read('spreadsheet.xls'); # Default Charset # Case of using Character Formats use Spreadsheet::ParseExcel::FmtJapan; # Many others available my $oFmtJ = Spreadsheet::ParseExcel::FmtJapan->new(Code => 'sjis'); # euc, jis, etc. my $xls = Spreadsheet::ParseExcel::Simple->read('spreadsheet.xls',$oFmtJ); This opens the spreadsheet specified for you. $formatObject is optional, used for non-default characters sets. 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, E<lt>kasei@tmtm.comE<gt>. =head1 SEE ALSO L<Spreadsheet::ParseExcel>. =head1 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. =cut sub read { my ($class,$sheetPath,$charFormatObject) = @_; my $book; if (defined $charFormatObject){ $book = Spreadsheet::ParseExcel->new->Parse($sheetPath,$charFormatObject) or return; } else { $book = Spreadsheet::ParseExcel->new->Parse($sheetPath) or return; } bless { book => $book }, $class; } sub book { shift->{book} } sub sheets {
From: "Bill Tribley" <bill [...] tribley.org>
To: "'Tony Bowden'" <kasei [...] tmtm.com>
Subject: RE: Spreadsheet::ParseExcel::Simple Suggested Change
Date: Fri, 21 May 2004 08:49:26 -0500
Hi Tony, I agree. I will try it out this weekend if I can. Bill Show quoted text
-----Original Message----- From: Tony Bowden [mailto:kasei@tmtm.com] Sent: Thursday, May 20, 2004 3:17 AM To: Bill Tribley Subject: Re: Spreadsheet::ParseExcel::Simple Suggested Change On Wed, May 19, 2004 at 09:37:46PM -0500, Bill Tribley wrote:
> Thank you for writing this Simple interface. I have been using it for > a year and liking it a lot!
Thanks.
> I have made a trivial modification in Spreadsheet::ParseExcel::Simple > which permits this. Would it be possible to include it in the distro?
This looks plausible, except I'd rather the following arguments came as a hashref rather than just a positional arg, in case I need to add more later. i.e. instead of my $xls = Spreadsheet::ParseExcel::Simple->read('spreadsheet.xls',$oFmtJ) I'd rather have: my $xls = Spreadsheet::ParseExcel::Simple->read('spreadsheet.xls', { format => $oFmtJ }); Or something similar to that. I'm a little busy at the minute to get this done, but I'll try to get round to it soon. Look OK? Thanks, Tony