从 Perl 程序解析特定 Excel 文件时出现内存不足错误

发布于 2024-07-14 07:54:03 字数 1856 浏览 4 评论 0原文

当 perl 代码运行时,程序会生成一些警告并终止。 输出如下:

D:\Perl\bin\search tool>perl testa.pl 
UTF-16 surrogate 0xdb79 at D:/Perl/site/lib/Spreadsheet/ParseExcel/FmtDefault.pm line 81. 
UTF-16 surrogate 0xdbb1 at D:/Perl/site/lib/Spreadsheet/ParseExcel/FmtDefault.pm line 81. 
UTF-16 surrogate 0xd83e at D:/Perl/site/lib/Spreadsheet/ParseExcel/FmtDefault.pm line 81. 
UTF-16 surrogate 0xdff8 at D:/Perl/site/lib/Spreadsheet/ParseExcel/FmtDefault.pm line 81. 
UTF-16 surrogate 0xdbff at D:/Perl/site/lib/Spreadsheet/ParseExcel/FmtDefault.pm line 81. 
UTF-16 surrogate 0xdd98 at D:/Perl/site/lib/Spreadsheet/ParseExcel/FmtDefault.pm line 81. 
substr outside of string at D:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 1196. 
Use of uninitialized value in unpack at D:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 1196. 
substr outside of string at D:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 1196.
Use of uninitialized value in unpack at D:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 1196. 
Out of memory! 

系统信息如下:

Perl 版本:5.010000 操作系统名称:MSWin32 模块版本:(并非全部都是必需的) 电子表格::ParseExcel 0.49 标量::Util 1.19 Unicode::Map(未安装) Spreadsheet::WriteExcel(未安装) Parse::RecDescent(未安装) 文件::温度 0.18 OLE::Storage_Lite 0.18 IO::Stringy 2.110

Perl 代码如下:

use strict; 
    use Spreadsheet::ParseExcel; 
    my $parser = Spreadsheet::ParseExcel->new( 
        CellHandler => \&cell_handler, 
        NotSetCell  => 1 
    ); 
    my $workbook = $parser->Parse('testfile.xls'); 
    sub cell_handler { 
        my $workbook    = $_[0]; 
        my $sheet_index = $_[1]; 
        my $row         = $_[2]; 
        my $col         = $_[3]; 
        my $cell        = $_[4]; 
        print $cell->unformatted(), "\n"; 
    }

我也有示例 testfile.xls。

When the perl code is run the program generates some warnings and terminates. The output is as below:

D:\Perl\bin\search tool>perl testa.pl 
UTF-16 surrogate 0xdb79 at D:/Perl/site/lib/Spreadsheet/ParseExcel/FmtDefault.pm line 81. 
UTF-16 surrogate 0xdbb1 at D:/Perl/site/lib/Spreadsheet/ParseExcel/FmtDefault.pm line 81. 
UTF-16 surrogate 0xd83e at D:/Perl/site/lib/Spreadsheet/ParseExcel/FmtDefault.pm line 81. 
UTF-16 surrogate 0xdff8 at D:/Perl/site/lib/Spreadsheet/ParseExcel/FmtDefault.pm line 81. 
UTF-16 surrogate 0xdbff at D:/Perl/site/lib/Spreadsheet/ParseExcel/FmtDefault.pm line 81. 
UTF-16 surrogate 0xdd98 at D:/Perl/site/lib/Spreadsheet/ParseExcel/FmtDefault.pm line 81. 
substr outside of string at D:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 1196. 
Use of uninitialized value in unpack at D:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 1196. 
substr outside of string at D:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 1196.
Use of uninitialized value in unpack at D:/Perl/site/lib/Spreadsheet/ParseExcel.pm line 1196. 
Out of memory! 

The system information is as below :

Perl version : 5.010000
OS name : MSWin32
Module versions: (not all are required)
Spreadsheet::ParseExcel 0.49
Scalar::Util 1.19
Unicode::Map (not installed)
Spreadsheet::WriteExcel (not installed)
Parse::RecDescent (not installed)
File::Temp 0.18
OLE::Storage_Lite 0.18
IO::Stringy 2.110

The perl code is as below :

use strict; 
    use Spreadsheet::ParseExcel; 
    my $parser = Spreadsheet::ParseExcel->new( 
        CellHandler => \&cell_handler, 
        NotSetCell  => 1 
    ); 
    my $workbook = $parser->Parse('testfile.xls'); 
    sub cell_handler { 
        my $workbook    = $_[0]; 
        my $sheet_index = $_[1]; 
        my $row         = $_[2]; 
        my $col         = $_[3]; 
        my $cell        = $_[4]; 
        print $cell->unformatted(), "\n"; 
    }

I have the sample testfile.xls also.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绝情姑娘 2024-07-21 07:54:03

此问题已在 此处的 Spreadsheet::ParseExcel Google 论坛上得到解答。

问题在于特定文件已加密。

约翰。

This question was answered on the Spreadsheet::ParseExcel Google Group here.

The problem is that the particular file is encrypted.

John.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文