Perl: Read Excel Cell Value


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”;
}

Advertisements

One thought on “Perl: Read Excel Cell Value

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s