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

In reply to Parse error in Spreadsheet::ParseExcel::Simple by igelkott

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.