与Perl的Excel文件中的列标题

我有一个有很多列的Excel文件,但我只需要对这三列进行一些计算。

我正在使用SpreadSheet::ParseExcel遍历我的Excel文件。 如何指定我想用perl的列?

 #!/usr/bin/perl -w use strict; use Spreadsheet::ParseExcel; my $parser = Spreadsheet::ParseExcel->new(); my $workbook = $parser->parse('Book1.xls'); if ( !defined $workbook ) { die $parser->error(), ".\n"; } for my $worksheet ( $workbook->worksheets() ) { my ( $row_min, $row_max ) = $worksheet->row_range(); my @columns = (1,5,6) # enter your 3 columns here for my $row ( $row_min .. $row_max ) { for my $col (@columns) { my $cell = $worksheet->get_cell( $row, $col ); next unless $cell; # do the calculations here print "Row, Col = ($row, $col)\n"; print "Value = ", $cell->value(), "\n"; print "Unformatted = ", $cell->unformatted(), "\n"; print "\n"; # operations done } } } 

来源: Spreadsheet :: ParseExcel模块的文档。