1

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.

simbabque
  • 53,749
  • 8
  • 73
  • 136
OJW
  • 4,514
  • 6
  • 40
  • 48

3 Answers3

1
foreach my $sheet ($excel->worksheets) {
    print $sheet->get_name;
}

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

daxim
  • 39,270
  • 4
  • 65
  • 132
1

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.

jmcnamara
  • 38,196
  • 6
  • 90
  • 108
0

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

OJW
  • 4,514
  • 6
  • 40
  • 48