Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: john [...] jspect.fastmail.com.au
Cc:
AdminCc:

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



Subject: xl-Simple update
Date: Fri, 21 Feb 2014 18:57:18 +1100
To: bug-Spreadsheet-ParseExcel-Simple [...] rt.cpan.org
From: John McMahon <john [...] jspect.fastmail.fm>
Hi Tony I have been using your ParseExcel-Simple module for sometime to read *.xls files and have recently started migrating to using *.xlsx files. With the recent discovery (by myself) of Jesse Luehrs ParseXLSX module, I am updating my applications, some of which use your Simple module. I have modified your Simple module to transparently open either .xls or .xlsx files. I have included my modified Simple.pm file in attached .zip file in the hope that you might consider releasing an update to CPAN. I have tagged my changes in the code but not in the POD. The only testing I have done is to successfully read some of my own files. For your consideration, below is an extract of the module showing most of the changes: [extract] use strict; use Spreadsheet::ParseExcel; use Spreadsheet::ParseXLSX; # 2014feb21jmcm use File::Basename; # 2014feb21jmcm =head1 NAME Spreadsheet::ParseExcel::Simple - A simple interface to Excel data =head1 SYNOPSIS my $xl = Spreadsheet::ParseExcel::Simple->read('spreadsheet.xls'); OR my $xl = Spreadsheet::ParseExcel::Simple->read('spreadsheet.xlsx'); foreach my $sheet ($xl->sheets) { while ($sheet->has_data) { my @data = $sheet->next_row; } } =head1 DESCRIPTION This provides an abstraction to the Spreadsheet::ParseExcel/ParseXLSX modules 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 $xl = Spreadsheet::ParseExcel::Simple->read('spreadsheet.xls'); OR my $xl = Spreadsheet::ParseExcel::Simple->read('spreadsheet.xlsx'); [ ... ] sub read { my $class = shift; my $xlfile = shift; @_ = fileparse($xlfile, ('.xls','.xlsx')); my $xltype = $_[2]; my $book; if ($xltype eq '.xls') { # 2014feb21jmcm my $parser = Spreadsheet::ParseExcel->new; $book = $parser->parse($xlfile) or return; } elsif ($xltype eq '.xlsx') { # 2014feb21jmcm my $parser = Spreadsheet::ParseXLSX->new; $book = $parser->parse($xlfile) or return; } else { # 2014feb21jmcm die "Abort - Invalid spreadsheet file type:\n\t$xlfile\n"; } bless { book => $book }, $class; } [\extract] Regards John PS. I will be travelling over the next week or so and do not expect to have regular internet access, so I may be tardy responding to any correspondence. -- Regards John McMahon john@jspect.fastmail.com.au 04 2933 4203
Download xlSimple.zip
application/octet-stream 1.8k

Message body not shown because it is not plain text.