igelkott has asked for the wisdom of the Perl Monks concerning the following question:
I'm using Spreadsheet::ParseExcel::Simple to copy data from excel files. This works most of the time but has failed for one of the eight (nearly identical) test files and I can't figure out why.
In this one file, the sheets returned by Spreadsheet::ParseExcel::Simple are not in the same order as found in excel. Actually, I can't find the data I want in any sheet until I delete the other sheets (manually in excel).
The simple conclusion is that this one file is somehow corrupt but a simple VB script (not shown out of respect to the group) finds the sheets in the right order and includes the desired data.
The simple hack shown below is what I've used to look for the missing data and discover the sheet ordering error. It simply echoes a few cells from each sheet and works as expected on the other test files. My real script runs on a unix system with Perl 5.8 but I get the same results on a windows machine (Perl 5.10).
#!/usr/bin/perl use strict; use warnings; use Spreadsheet::ParseExcel::Simple; my $as_file = shift or die("Victim required"); my $xls = Spreadsheet::ParseExcel::Simple->read("$as_file") or die("Ex +cel unread"); my $s = 0; for my $sheet ($xls->sheets) { $s++; my $n = 0; print "#################################\n"; print " sheet $s\n"; print "#################################\n"; while ($sheet->has_data) { $n++; my @d = $sheet->next_row; $#d = 3 if @d > 3; print join("\t", @d), "\n"; last if $n > 10; } }
It may just be some pathological problem with this particular excel file so that the real issue is completely off-topic but thought I'd at least see if there's something simple I'm missing or if others have seen parsing errors with this module.
TIA, iggi
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Parse error in Spreadsheet::ParseExcel::Simple
by roboticus (Chancellor) on Apr 21, 2008 at 13:49 UTC | |
by igelkott (Priest) on Apr 21, 2008 at 15:39 UTC | |
by roboticus (Chancellor) on Apr 22, 2008 at 17:58 UTC | |
by igelkott (Priest) on Apr 22, 2008 at 19:51 UTC | |
Re: Parse error in Spreadsheet::ParseExcel::Simple
by Aim9b (Monk) on Apr 21, 2008 at 11:15 UTC | |
by igelkott (Priest) on Apr 21, 2008 at 15:20 UTC |