in reply to Spreadsheet::ParseExcel::Simple, reading specific cells?

From the docs:
@sheets = $xls->sheets;
Each spreadsheet can contain one or more worksheets. This fetches them all back. You can then iterate over them, or jump straight to the one you wish to play with.
So, to get, for example, the 3rd worksheet you can do something like $thirdsheet = ($xls->sheets)[3];
In your example, you are getting the 6th column, which consists of the 6th element in each single row.
As far as I see it, the only way to get a specific row, is in an empty for-loop:
for (1..5) { # skip first five rows $sheet->has_data or die "Can't get 5th row: Too few rows\n"; $sheet->next_row; } my @data = $sheet->next_row;
Hope this helps (and works - this computer doesn't have Excel installed, so it's untested).
Addendum: You might be interested in the Spreadsheet::ParseExcel module, which has a broader variety of commands. Specifically, you can get the contents of single cells from a worksheet.

Replies are listed 'Best First'.
Re: Re: Spreadsheet::ParseExcel::Simple
by Anonymous Monk on Aug 24, 2003 at 18:50 UTC
    I tried lookin through the Spreadsheet::ParseExcel module too...but, I couldn't really understand how to get the program to scroll through columns and rows. Like, I'm considering using 2 for loops. The first go through the rows, while the second one goes down the column inside the row. Anyways, the problem is that the ParseExcel module doesn't really offer a good explanation of how I'd go about doing this.
      If you should afterall be interested in Spreadsheet::ParseExcel, then maybe the following code from the docs (after naming the variables with slightly better readable names) is going to help you
      use strict; use Spreadsheet::ParseExcel; my $BookObject = Spreadsheet::ParseExcel::Workbook->Parse('Excel/Test9 +7.xls'); foreach my $WorksheetObject (@{$BookObject->{Worksheet}}) { print "--------- SHEET:", $WorksheetObject->{Name}, "\n"; for(my $RowIndex = $WorksheetObject->{MinRow}; # starting at minimu +m row value defined $WorksheetObject->{MaxRow} && $RowIndex <= $WorksheetObject->{MaxRow}; # ending at maximum +row value $RowIndex++) { for (my $ColumnIndex = $WorksheetObject->{MinCol}; defined $WorksheetObject->{MaxCol} && $ColumnIndex <= $WorksheetObject->{MaxCol}; $ColumnIndex++) { $CellObject = $WorksheetObject->{Cells}[$RowIndex][$ColumnIn +dex]; # get cell print "( $RowIndex , $ColumnIndex ) =>", $CellObject->Value, "\n" # print cell contents ... if ($CellObject); # ... if cell exists } } }
      Overview over the Spreadsheet::ParseExcell class:
      class Spreadsheet::ParseExcel
          | via ->Parse
         class Spreadsheet::ParseExcel::Workbook
             | via ->{Worksheet}
            class Spreadsheet::ParseExcel::Worksheet
                 | via ->{Cells}[$Row][$Column]
               class Spreadsheet::ParseExcel::Cell
      And as well, but not so important:
      class Spreadsheet::ParseExcel::Format
      class Spreadsheet::ParseExcel::Font
      class Spreadsheet::ParseExcel::Fmt
      Hope this helped.
      CombatSquirrel.