This queue is for tickets about the Spreadsheet-ParseExcel CPAN distribution.
Maintainer(s)' notes
If you are reporting a bug in Spreadsheet::ParseExcel here are some pointers
1) State the issues as clearly and as concisely as possible. A simple program or Excel test file (see below) will often explain the issue better than a lot of text.
2) Provide information on your system, version of perl and module versions. The following program will generate everything that is required. Put this information in your bug report.
#!/usr/bin/perl -w
print "\n Perl version : $]";
print "\n OS name : $^O";
print "\n Module versions: (not all are required)\n";
my @modules = qw(
Spreadsheet::ParseExcel
Scalar::Util
Unicode::Map
Spreadsheet::WriteExcel
Parse::RecDescent
File::Temp
OLE::Storage_Lite
IO::Stringy
);
for my $module (@modules) {
my $version;
eval "require $module";
if (not $@) {
$version = $module->VERSION;
$version = '(unknown)' if not defined $version;
}
else {
$version = '(not installed)';
}
printf "%21s%-24s\t%s\n", "", $module, $version;
}
__END__
3) Upgrade to the latest version of Spreadsheet::ParseExcel (or at least test on a system with an upgraded version). The issue you are reporting may already have been fixed.
4) Create a small example program that demonstrates your problem. The program should be as small as possible. A few lines of codes are worth tens of lines of text when trying to describe a bug.
5) Supply an Excel file that demonstrates the problem. This is very important. If the file is big, or contains confidential information, try to reduce it down to the smallest Excel file that represents the issue. If you don't wish to post a file here then send it to me directly: jmcnamara@cpan.org
6) Say if the test file was created by Excel, OpenOffice, Gnumeric or something else. Say which version of that application you used.
7) If you are submitting a patch you should check with the maintainer whether the issue has already been patched or if a fix is in the works. Patches should be accompanied by test cases.
Asking a question
If you would like to ask a more general question there is the Spreadsheet::ParseExcel Google Group.
Owner: |
Nobody in particular
|
Requestors: |
tlhackque [...] yahoo.com
|
Cc: |
|
AdminCc: |
|
|
Severity: |
(no value)
|
Broken in: |
0.59 |
Fixed in: |
0.62 |
|
Tue Feb 18 11:01:50 2014
tlhackque [...] yahoo.com - Ticket created
Same environment (versions, writer, etc) as rt #93065
It seems that a spreadsheet can have no column information record.
In this case, Spreadsheet::ParseExcel::Worksheet::get_col_width() attempts to dereference an array that doesn't exist. This results in an exception:
"Can't use an undefined value as an ARRAY reference at /usr/lib/perl5/site_perl/5.8.8/Spreadsheet/ParseExcel/Worksheet.pm line 201."
The fix is probably to do something like:
sub get_col_widths {
my $self = shift;
unless( exists $self->{ColWidth} ) {
return ();
}
return @{ $self->{ColWidth} };
}
Arguably, it could return ( ((undef()) x (# columns) ), but I'm not sure that's worthwhile.
Note that this failure is on the second worksheet of a workbook - I wonder if the reader is expected to copy the column widths from the previous sheet? Just a guess; the M$ spec is short on semantics.
I suppose this could also happen with get_row_heights ({RowHeight}). It may be worth a general sweep for similar bugs.
Attached is a spreadsheet that demonstrates this case. As in the referenced bug, this was generated with Microsoft Excel 2003.
**** While debugging this, I noticed that the parser decodes the workbook's author and stores it in the book's {Author} field. It would be useful (and trivial) to add an accessor to return this to the user.
The following test program dumps the worksheet on failure; we can see that the {ColWidth} element is missing from the worksheet hash. Run it with the spreadsheet as the command line argument.
#!/usr/bin/perl
use warnings;
use strict;
use Spreadsheet::ParseExcel;
use Data::Dumper;
$Data::Dumper::Sortkeys=1;
my $ss=Spreadsheet::ParseExcel->new;
unless( $ss ) {
print STDERR "Init failed $ARGV[0]\n";
exit;
}
my $wb=$ss->parse($ARGV[0]);
unless( $wb ) {
print STDERR "Parse failed $ARGV[0]\n";
exit;
}
my $ws=$wb->worksheet(1); # **** N.B. Second worksheet
my @rh = $ws->get_row_heights;
eval {
my @cw = $ws->get_col_widths;
}; if( $@ ) {
print "Failed:\n", Dumper( $ws );
} else {
print "OK";
}
exit;
Message body not shown because it is not plain text.
Tue Mar 04 19:14:52 2014
DOUGW [...] cpan.org - Correspondence added
On Tue Feb 18 11:01:50 2014, tlhackque wrote:
Show quoted text>
> In this case, Spreadsheet::ParseExcel::Worksheet::get_col_width()
>
> The fix is probably to do something like:
> sub get_col_widths {
>
> my $self = shift;
> unless( exists $self->{ColWidth} ) {
> return ();
> }
Looks like your patch had:
unless $self->{RowHeight}
where it should have had 'ColWidth'...I'll fix and release another version.
Tue Mar 04 19:14:52 2014
The RT System itself - Status changed from 'new' to 'open'
Tue Mar 04 19:23:53 2014
DOUGW [...] cpan.org - Correspondence added
On Tue Mar 04 19:14:52 2014, DOUGW wrote:
Show quoted text> On Tue Feb 18 11:01:50 2014, tlhackque wrote:
>
> where it should have had 'ColWidth'...I'll fix and release another version.
And actually, I'm thinking that a function that normally returns an array of elements should not return a one element array in this case, and instead just return zero elements:
return unless $self->{ColWidth};
return @{ $self->{ColWidth} };
The docs and the comments say the function returns an array ref...should probably fix the those also...
Tue Mar 04 20:09:29 2014
DOUGW [...] cpan.org - Correspondence added
On Tue Mar 04 19:23:53 2014, DOUGW wrote:
Show quoted text>
> The docs and the comments say the function returns an array
> ref...should probably fix the those also...
Or...other similar functions say they return an array ref, and actually do...and, the docs do say to return 'undef' if the property is not set, so, my inclination is to use wantarray() to return either a (possibly empty) array, or the array ref (or 'undef' if property is not set)...in order to introduce the least amount of backward incompatibility.
Fri Mar 07 15:49:20 2014
DOUGW [...] cpan.org - Correspondence added
Fri Mar 07 15:49:21 2014
DOUGW [...] cpan.org - Status changed from 'open' to 'resolved'