I had problems with reading XLS files with Spreadsheet::ParseExcel and ending up with a last row which was all undefs. I came up with:
next if @row == grep !$_, @row;I think that looks quire nice :)
Re:truth
gav on 2002-07-18T22:23:38
grep in scalar context returns the number of items in the array that matched. I'm trying to make sure that there is at least 1 non-false value in the row. A row of all zeros would cause it to be skipped, but then that's bad data anyway:) Probably this would have been more clear:
The module doesn't return rows in any nice way, it's a fantastically useful module but the interface seems too much like Visual Basic for my liking:next unless grep $_, @row;foreach my $r ($sheet->{MinRow}+1.. $sheet->{MaxRow}) {
my @row = map { $_ ? $_->Value : undef } @{$sheet->{Cells}[$r]}[0..$cols];
push @items, \@row;
}On my to-do list is write a wrapper, Spreadsheet::ParseExcel::Simple or somesuch.
Re:truth
jdavidb on 2002-07-19T15:35:16
I like the DBD::Excel wrapper, myself, but it may not suit your purposes.