A sample code to read excel cell value by using Spreadsheet::ParseExcel module.
#!/user/bin/perl -w
use strict;
use Spreadsheet::ParseExcel;
#Parse excel file
my $parser = Spreadsheet::ParseExcel->new();
my $workbook = $parser->parse(“test.xls”);
#Get cell value from excel sheet1 row 1 column 2
my $worksheet = $workbook->worksheet(‘sheet1’);
my $cell = $worksheet->get_cell(1,2);
# Print the cell value when not blank
if ( defined $cell and $cell->value() ne ” ) {
my $value = $cell->value();
print “cell value is $value \n”;
}
can u help me also with comparing a string with excel and print the entire column if the string is matching?
If i leave out that test like if(defined($cell)) i get an error when i try to process blank cells.
But if i do put it in, all $cell fail the test.
???
So if i leave it out i get most of my work done but it crashes at the end.
If i put it in, the code just never executes $cell->value()