运行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 模块版本:(并非所有都需要) Spreadsheet :: ParseExcel 0.49 Scalar :: Util 1.19 Unicode :: Map(未安装) Spreadsheet :: WriteExcel(未安装) Parse :: RecDescent(未安装) File :: Temp 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。