簡體   English   中英

為什么Perl的Spreadsheet :: ParseExcel永遠不會從$ parser-> parse('test.xls')返回?

[英]Why doesn't Perl's Spreadsheet::ParseExcel never return from $parser->parse('test.xls')?

該電子表格與Excel 97-2003兼容且權限為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__; 

您是否使用最新的Spreadsheet :: ParseExcel 當前版本是0.57。

我看到您將此作為CGI運行。 您可以從命令行(在本地使用相同的測試文件)運行它,並檢查是否有任何錯誤消息嗎?

也嘗試使用eval(從命令行運行仍然更好)並檢查$ parser是否已定義:

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

嘗試另一個Excel文件。

如果錯誤仍然未知,並且帶有特定的Excel文件,請在Bug Tracker中報告錯誤。

我是Spreadsheet :: ParseExcel的維護者。

parse()方法僅在更新的版本中可用。 建議進行升級以獲取最新的錯誤修復。

較新的版本還具有error()和error_code()方法來報告解析錯誤。

約翰。

一旦發現使用eval,我就嘗試使用一種不存在的方法(如Alexandra-ciornii所推薦)

對我有用的是什么

$workbook = Spreadsheet::ParseExcel::Workbook->Parse('test.xls');

聽起來像文件路徑問題比什么都重要。 您是否嘗試過為parse函數提供絕對路徑? 示例:$ parser-> parse('/ usr / local / www / host / htdocs / test.xls');

如果它確實永遠不會返回,那么它一定會陷入某種無限循環中。 嘗試使用Perl調試器在命令行上運行腳本。

~$ perl -d my_script.pl

請注意,CGI腳本也可以通過這種方式讀取,並且它們接受KEY = VAL形式的命令行參數,如下所示:

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

如果您鍵入“ h”,perl調試器將告訴您可接受的命令列表,但是最重要的是:

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

如果發現存在無限循環問題,請在http://rt.cpan.org (特別是在這里: https ://rt.cpan.org/Public/Dist/Display)上將其作為錯誤提交。 html?Name = Spreadsheet-ParseExcel

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM