假設我的數據是:
一種方法是做你想要的(因爲 'd' 對應於第4列):
$ cat a.pl
use strict;
use warnings;
use feature 'say';
use Spreadsheet::Read;
use Spreadsheet::ParseExcel;
use Data::Dumper;
my $workbook = ReadData ("/tmp/file.xls", parser => "xls");
print Dumper($workbook->[1]{cell}[4]);
foreach my $cell (@{$workbook->[1]{cell}[4]}) {
if ($cell) {
print $cell . "\n";
}
}
$ perl a.pl
$VAR1 = [
undef,
'grid',
1115,
1512,
212
];
grid
1115
1512
212
另一個方法是使用Spreadsheet::BasicReadNamedCol:
$ cat a.pl
use strict;
use warnings;
use feature 'say';
use Spreadsheet::BasicReadNamedCol;
use Data::Dumper;
my @columnHeadings = (
'grid',
);
my $workbook = new Spreadsheet::BasicReadNamedCol("/tmp/file.xls");
$workbook->setColumns(@columnHeadings);
while (my $data = $workbook->getNextRow()) {
print "@{$data}[0]\n";
}
$ perl a.pl
grid
1115
1512
212
非常感謝您的詳細解答。它有助於。 –