ParseExcel::Simple not working?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Apparently many people find ParseExcel and ParseExcel::Simple very
useful, but I have not been able to get it working. After reading
extensively in the perl newsgroups and testing all I can, am hoping
someone else might help me spot what's amiss. Having the ability to
read spreadsheets directly from Perl would have great value where I
work, so I'm hoping this will happen!

Here's the (relevant) code:

use Getopt::Std;
use IBG::StudyIDparser;
use FileHandle;
use DBI;
use OLE::Storage_Lite;
use Spreadsheet::ParseExcel;
use Spreadsheet::ParseExcel::Simple;

$rootdir = '/mydir/';
$filelist = "mySSlist.txt";
open (FILELIST,"< $filelist") or die "Could not open input file:
while (<FILELIST>) {
    if (! -f $_) {
        die "File $_ not found!\n";
    $ss_file = $rootdir.$_;
    print "Processing $_\n";
    # For now:
    #      Just print out rows as a test....
    my $xls = Spreadsheet::ParseExcel::Simple->read('$ss_file');
    my $sheet = ($xls->sheets)[0]; # all the spreadsheets have just one
    while ($sheet->has_data) {
        my @data = $sheet->next_row;
        print @data;

Here's the error message:
Can't call method "sheets" on an undefined value at line
...., <FILELIST> line ...

Any help appreciated,

Re: ParseExcel::Simple not working?

Quoted text here. Click to load it

Have you tried getting a program to read a single spreadsheet before
getting it to read a list of spreadsheets? Walk before you run!

Quoted text here. Click to load it

You test $_ for existence and print $_, but you are processing
"/mydir/$_". Try checking the string in $ss_file for existence. If
/mydir/ is not your default directory, that is your first problem.

Quoted text here. Click to load it

You do not test $xls before trying to use it. The error message you get
tells you that it is undefined. The documentation says that the read
method returns undefined if it "cannot read the book" (workbook). You
are trying to read a spreadsheet document called (literally)
'$ss_file'. Remove the single quotes (double quotes might work but are

   my $xls = Spreadsheet::ParseExcel::Simple->read($ss_file);
   die("Can't read $ss_file") unless defined $xls;

Quoted text here. Click to load it

Site Timeline