I am writing a PERL code to pick values from specific rows of a particular excel sheet. I am using the Spreadsheet::ParseExcel module for this purpose. I have written this code as of now
use Spreadsheet::ParseExcel::FmtDefault; use Spreadsheet::ParseExcel; my $parser = Spreadsheet::ParseExcel->new(); #my $name = <STDIN>; die "You must provide a filename to $0 to be parsed as an Excel file" unless @ARGV; my $workbook = $parser->parse($ARGV[0]); my @values; 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; $cell->value(); my $cell_type = $cell->{Type}; if ($cell_type =~/Numeric/) { push @values, $cell->unformatted(); } } } }
I am able to pick all the numeric values in a particular excel sheet with this particular code, but I would like to tweak the code so that it could pick up numeric values in specific columns as per the users needs (eg: all the numeric values in row B or row C). How do I go about tweaking my code to make that possible or are there simpler modules available in which the range (eg B2 - B22) can be specified. Any help is appreciated.