我安装了Spreadsheet :: ParseExcel模块,并添加了该模块示例中显示的脚本来解析XLS文件。除了一件事之外,它的效果很好:它不会拉出单元格中的图像。 关于如何在细胞中获取图像的任何想法? 无论是cell->值还是cell-> unformatted,当它们遇到单元格中的图像时,都不会得到任何内容(空白)。
以下是代码:
#!/usr/bin/perl -w
use strict;
use Spreadsheet::ParseExcel;
my $parser = Spreadsheet::ParseExcel->new();
my $workbook = $parser->parse('myworkbook.xls');
if (!defined $workbook)
{
die $parser->error(), ".\n";
}
for my $worksheet ($workbook->worksheets())
{
my ($row_min, $row_max) = $worksheet->row_range();
my ($col_min, $col_max) = $worksheet->col_range();
for my $row($row_min .. $row_max)
{
for my $col ($col_min .. $col_max)
{
my $cell = $worksheet->get_cell($row, $col);
next unless $cell;
print "Row, Col = ($row, $col)\n";
print "Value = ", $cell->value(), "\n";
print "Unformatted = ", $cell->unformatted(), "\n";
print "\n";
}
}
}