views:

451

answers:

5

The spreadsheet is Excel 97-2003 compatible and permissions 777

use strict;
use Spreadsheet::ParseExcel;
print "Content-type: text/html\n\n";   
my $parser   = Spreadsheet::ParseExcel->new();
print "<br>gets here:".__LINE__; 
my $workbook = $parser->parse('test.xls');
print "<br>never gets here:".__LINE__; 
A: 

Sounds like a file-path issue more than anything. Have you tried giving the parse function an absolute path? Example: $parser->parse('/usr/local/www/host/htdocs/test.xls');

drlouie - louierd
+4  A: 

Do you use latest Spreadsheet::ParseExcel? Current version is 0.57.

I see that you run this as CGI. Can you run it from command line (locally, with same test file) and check if there is any error message?

Try also using eval (running from command line is still better) and check if $parser is defined:

print '$parser is undef<br>' unless defined $parser;
eval {
  my $workbook = $parser->parse('test.xls');
};
print "Error message from eval: $@<br>";

Try another Excel file.

If error still is unknown and with specific Excel file, report bug in bug tracker.

Alexandr Ciornii
blush:-Error message from eval: Can't locate object method "parse" via package "Spreadsheet::ParseExcel" at ...thanks
zzapper
A: 

If it truly is never returning then it must be getting stuck in some kind of infinite loop. Try running your script on the command line using the Perl debugger.

~$ perl -d my_script.pl

Note that CGI scripts can also be read in this way, and that they accept command line arguments in the form KEY=VAL like so

~$ perl -d my_cgi.cgi var=foo var2=bar bananas=delicious

The perl debugger will tell you a list of commands it accepts if you type 'h', but the most important ones are:

n: go to the next line

s: step into the next line (if it is a sub, otherwise is identical to 'n')

v: view the next few lines (can be used repeatedly)

c: continue to a line or subroutine

If you find that there is some kind of infinite loop problem, then submit it as a bug on http://rt.cpan.org (specificially, here: https://rt.cpan.org/Public/Dist/Display.html?Name=Spreadsheet-ParseExcel)

Kaoru
A: 

Hi Once I found I was trying to use an inexistant method thanks to using eval (as recommended by alexandr-ciornii)

What did work for me

$workbook = Spreadsheet::ParseExcel::Workbook->Parse('test.xls');
zzapper
The cpan page does say parse not Parse, so this isn't your fault.
Chris Huang-Leaver
+2  A: 

I am the maintainer of Spreadsheet::ParseExcel.

The parse() method is only available in more recent versions. An upgrade is recommended to pick up the latest bug-fixes.

The newer versions also have error() and error_code() methods to report parse errors.

John.

jmcnamara