user16121622
user16121622

Reputation:

How to read Excel file in Perl by sheet name

I am looking for some examples/advice on how to write a Perl script to read data from an Excel file by sheet name and not sheet number. This is an example with Spreadsheet, but it doesn't work with sheet name:

#Code Perl :
use Spreadsheet::Read qw(ReadData);
{
    my $book  = ReadData ("test.xls");
    my $sheet = $book->sheet ("name_3");
    my @rows = rows ($sheet);
    ...
} 

Can you help me please?

Upvotes: 3

Views: 761

Answers (1)

toolic
toolic

Reputation: 62045

It works for me when I use the OO API:

use warnings;
use strict;
use Spreadsheet::Read;

my $book  = Spreadsheet::Read->new('test.xls');
my $sheet = $book->sheet('Sheet1');
my @rows  = $sheet->rows();

Upvotes: 2

Related Questions