Amphiaraus has asked for the wisdom of the Perl Monks concerning the following question:

When I run the program shown here:
#!C:\strawberry\perl\bin\perl.exe use strict; use warnings; use Spreadsheet::ParseExcel; use Spreadsheet::ParseExcel::SaveParser; # Specify cell H2’s row and col my $row = 1; my $col = 7; my $worksheet_num = 0; # Create a parser that can read/write/display cells in an existing Exc +el spreadsheet my $parser = Spreadsheet::ParseExcel::SaveParser->new(); if ($parser) { print "parser is defined\n"; } else { print "parser is NOT defined\n"; } # Parse the ‘Build_Scheduler.xlsx’ spreadsheet my $template = $parser->Parse('Build_Scheduler.xlsx'); if ($template) { print "template is defined\n"; } else { print "template is NOT defined\n"; } # Specify leftmost tab (“0”) as the worksheet to be modified my $worksheet = $template->worksheet(0) || die("$@$!"); # Overwrite the AsOf string value in tab = “Monday”, cell H2. (05/05/2 +016 2:00PM is replaced by 05/05/2016 2:00PM) $worksheet->AddCell( $row, $col, '05/12/2016 2:00PM' );
I find the the call to my $template $parser->Parse('Build_Scheduler.xlsx') fails and returns "undefined", causing the later call my $worksheet = $template->worksheet(0) to fail. My Perl version is Strawberry 5.18.1001 Can someone let me know why my
$template = $parser->Parse('Build_Scheduler.xlsx'); is failing?
Currently I see no syntax or logic errors in the above program.
I am following the CPAN examples for the relevant modules exactly.
  • Comment on Having Problems with Spreadsheet::ParseExcel::SaveParser Parse() function
  • Download Code

Replies are listed 'Best First'.
Re: Having Problems with Spreadsheet::ParseExcel::SaveParser Parse() function
by Athanasius (Archbishop) on May 09, 2016 at 15:05 UTC
Re: Having Problems with Spreadsheet::ParseExcel::SaveParser Parse() function
by Corion (Patriarch) on May 09, 2016 at 15:02 UTC
Re: Having Problems with Spreadsheet::ParseExcel::SaveParser Parse() function
by toolic (Bishop) on May 09, 2016 at 15:04 UTC
    Spreadsheet::ParseExcel has an error function. It's worth a try:
    if ($template) { print "template is defined\n"; } else { print "template is NOT defined\n"; die $parser->error(), ".\n"; }
      Too late for this thread, I found in this Module's documentation that it cannot read Excel files in xlsx format. This thread should be considered closed.