Home: Perl Programming Help: Intermediate:
Unable assign value from excel sheet cell to a variable



suvendra
New User

Jan 8, 2017, 9:10 PM


Views: 1465
Unable assign value from excel sheet cell to a variable

I want to assign value to the variable expected_cfg_e25ga_config but it is not taking the value from excelsheet from cell 1,1. How to assign the value. Thank you in advance

use strict;
use Spreadsheet::ParseExcel;

my $parser = Spreadsheet::ParseExcel->new();
my $workbook = $parser->parse('d:/xyz1.xls');

if ( !defined $workbook ) {
die $parser->error(), ".\n";
}
#my $worksheet = $workbook->worksheet();
for my $worksheet ( $workbook->worksheets() ) {

my ( $row_min, $row_max ) = $worksheet->row_range();
my ( $col_min, $col_max ) = $worksheet->col_range();

foreach my $row ( $row_min .. $row_max ) {
foreach 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";
print "expected_cfg_e25ga_config =" , $cell->value(1,1) , "\n"

}
}
;
}



Laurent_R
Veteran / Moderator

Jan 8, 2017, 11:09 PM


Views: 1462
Re: [suvendra] Unable assign value from excel sheet cell to a variable

Do you have this problem only with cell 1,1, or for any cell in the sheet?

Please use code tags for your code samples, itg would make it easier to read.