ParseExcel worksheet get_name()

2k Views Asked by At

Using certain old versions of ActivePerl, reading a spreadsheet:

use Spreadsheet::ParseExcel;
$excel = Spreadsheet::ParseExcel::Workbook->Parse("some file");
foreach $sheet (@{$excel->{Worksheet}}){
  print $sheet->get_name(); 
}

Error: Can't locate object method get_name() spreadsheet::parseexcel::worksheet

Also $sheet->{name} doesn't give anything.

3

There are 3 best solutions below

1
OJW On

$sheet->{Name} (with uppercase) gives the name, in v0.49 of ParseExcel

0
daxim On
foreach my $sheet ($excel->worksheets) {
    print $sheet->get_name;
}

works. You are supposed to call the worksheets method to get at the Worksheets objects.

0
jmcnamara On

Versions of Spreadsheet::ParseExcel prior to 0.43 (January 2009) didn't have a get_name() method.

If you upgrade to a recent version of Spreadsheet::ParseExcel then your code will work. I tested it.

However, Spreadsheet::ParseExcel::Workbook->Parse() is now deprecated since it doesn't do error checking. Use Spreadsheet::ParseExcel->Parse() instead.