bgaber has asked for the wisdom of the Perl Monks concerning the following question:

Attempting to use Spreadsheet::Read and find its documentation rather sparse. I can read a cell, but cannot read an entire row or entire sheet using the row or rows functions.
Tried both of these
use Spreadsheet::Read; use Spreadsheet::Read qw(row rows);
Here is my code:
my $ref2 = ReadData ("test.xls"); my @row = row($ref2, 6);<br> for (my $i=0; $i<=$#row; $i++) { print "$row[$i]\n"; } my @rows = rows($ref2); # print the whole thing one at a time for $i ( 0 .. $#rows ) { for $j ( 0 .. $#{$rows[$i]} ) { print "element $i $j is $rows[$i][$j]\n"; } }
with this use:
use Spreadsheet::Read; I get this error: Undefined subroutine &main::row
with this use:
use Spreadsheet::Read qw(row rows); I don't get the error, but do not get any data output.

Replies are listed 'Best First'.
Re: Read entire row and/or sheet with Spreadsheet::Read
by runrig (Abbot) on Jan 24, 2012 at 18:49 UTC
    row() needs a reference to the sheet. So this should work to get the 6th row of the 1st sheet:
    use Spreadsheet::Read qw(row rows); my $ref2 = ReadData ("test.xls"); my @row = row($ref2->[1], 6);
Re: Read entire row and/or sheet with Spreadsheet::Read
by toolic (Bishop) on Jan 24, 2012 at 18:07 UTC
    The POD for Spreadsheet::Read mentions a "debug" option:
    Enable some diagnostic messages to STDERR. The value determines how much diagnostics are dumped (using Data::Dumper). A value of 9 and higher will dump the entire structure from the back-end parser.
    use Spreadsheet::Read qw(row rows); my $ref2 = ReadData ("test.xls", debug => 9);
Re: Read entire row and/or sheet with Spreadsheet::Read
by bgaber (Novice) on Jan 24, 2012 at 19:22 UTC

    Thanks.

    my @row = row($ref2->[1], 6);

    fixed my problem.