Subject: | Hidden rows and column attributes aren't exposed |
As others have reported, hidden rows and columns aren't reported to the user.
The logic is almost there in S:P:E. Here is a workaround that exposes the hidden attribute.
This is coded as a subclass of Spreadsheet::Parse::Excel; it should be incorporated more directly into the code. (It's trivial, but I don't want to fork the module.)
Replace your new code to call Spreadsheet::ParseExcel::Extended->new.
Two new worksheet APIs result:
is_row_hidden($row) and is_col_hidden($col)
in scalar context, return true if the specified row/column is hidden.
in array context, return an array [col 0 .. lastCol] of values. (The argument is ignored.)
There is no guarantee that the package maintainer (when one is found) will provide the same API - but I hope (s)he will.
package Spreadsheet::ParseExcel::Extended;
our @ISA = (qw/Spreadsheet::ParseExcel/);
sub new {
my $class = shift;
$Spreadsheet::ParseExcel::ProcTbl{0x208} = \&_subRow;
$Spreadsheet::ParseExcel::ProcTbl{0x7D} = \&_subColInfo;
return $class->SUPER::new(@_);
}
sub _subRow {
my ( $oBook, $bOp, $bLen, $sWk ) = @_;
return undef unless ( defined $oBook->{_CurSheet} );
#0. Get Worksheet info (MaxRow, MaxCol, MinRow, MinCol)
my ( $iR, $iSc, $iEc, $iHght, $undef1, $undef2, $iGr, $iXf ) =
unpack( "v8", $sWk );
if ( $iGr & 0x20 ) {
$oBook->{Worksheet}[ $oBook->{_CurSheet} ]->{RowHidden}[$iR] = 1;
}
Spreadsheet::ParseExcel::_subRow(@_);
}
sub _subColInfo {
my ( $oBook, $bOp, $bLen, $sWk ) = @_;
return undef unless defined $oBook->{_CurSheet};
my ( $iSc, $iEc, $iW, $iXF, $iGr ) = unpack( "v5", $sWk );
for ( my $i = $iSc ; $i <= $iEc ; $i++ ) {
if ( $iGr & 0x01 ) {
$oBook->{Worksheet}[ $oBook->{_CurSheet} ]->{ColHidden}[$i] = 1;
}
}
Spreadsheet::ParseExcel::_subColInfo(@_);
}
package Spreadsheet::ParseExcel::Worksheet;
=head2 is_row_hidden($row)
In scalar context, return true if $row is hidden
In array context, return an array whose elements are true
if the corresponding row is hidden.
=cut
sub is_row_hidden {
my $worksheet = shift;
my ($row) = @_;
unless ( $worksheet->{RowHidden} ) {
return () if (wantarray);
return 0;
}
return @{ $worksheet->{RowHidden} } if (wantarray);
return $worksheet->{RowHidden}[$row];
}
=head2 is_col_hidden($col)
In scalar context, return true if $col is hidden
In array context, return an array whose elements are true
if the corresponding column is hidden.
=cut
sub is_col_hidden {
my $worksheet = shift;
my ($col) = @_;
unless ( $worksheet->{ColHidden} ) {
return () if (wantarray);
return 0;
}
return @{ $worksheet->{ColHidden} } if (wantarray);
return $worksheet->{ColHidden}[$col];
}