diff options
-rw-r--r-- | lib/Spreadsheet/ParseXLSX.pm | 6 | ||||
-rw-r--r-- | t/data/hidden-row-and-column.xlsx | bin | 0 -> 7467 bytes | |||
-rw-r--r-- | t/hidden-row-and-column.t | 17 |
3 files changed, 23 insertions, 0 deletions
diff --git a/lib/Spreadsheet/ParseXLSX.pm b/lib/Spreadsheet/ParseXLSX.pm index 535063a..037803a 100644 --- a/lib/Spreadsheet/ParseXLSX.pm +++ b/lib/Spreadsheet/ParseXLSX.pm @@ -148,7 +148,9 @@ sub _parse_sheet { my @column_formats; my @column_widths; + my @columns_hidden; my @row_heights; + my @rows_hidden; my $default_row_height = 15; my $default_column_width = 10; @@ -253,6 +255,7 @@ sub _parse_sheet { for my $colnum ($col->att('min')..$col->att('max')) { $column_widths[$colnum - 1] = $col->att('width'); $column_formats[$colnum - 1] = $col->att('style'); + $columns_hidden[$colnum - 1] = $col->att('hidden'); } $twig->purge; @@ -262,6 +265,7 @@ sub _parse_sheet { my ( $twig, $row ) = @_; $row_heights[ $row->att('r') - 1 ] = $row->att('ht'); + $rows_hidden[ $row->att('r') - 1 ] = $row->att('hidden'); $twig->purge; }, @@ -396,10 +400,12 @@ sub _parse_sheet { $sheet->{RowHeight} = [ map { defined $_ ? 0+$_ : 0+$default_row_height } @row_heights ]; + $sheet->{RowHidden} = \@rows_hidden; $sheet->{ColWidth} = [ map { defined $_ ? 0+$_ : 0+$default_column_width } @column_widths ]; $sheet->{ColFmtNo} = \@column_formats; + $sheet->{ColHidden} = \@columns_hidden; } diff --git a/t/data/hidden-row-and-column.xlsx b/t/data/hidden-row-and-column.xlsx Binary files differnew file mode 100644 index 0000000..4d4bac4 --- /dev/null +++ b/t/data/hidden-row-and-column.xlsx diff --git a/t/hidden-row-and-column.t b/t/hidden-row-and-column.t new file mode 100644 index 0000000..cd18c70 --- /dev/null +++ b/t/hidden-row-and-column.t @@ -0,0 +1,17 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; + +use Spreadsheet::ParseXLSX; + +my $wb = Spreadsheet::ParseXLSX->new->parse('t/data/hidden-row-and-column.xlsx'); +my $ws = $wb->worksheet(0); + +ok(!$ws->is_row_hidden(0), 'Regular row is not hidden'); +ok( $ws->is_row_hidden(1), 'Hidden row is hidden'); + +ok(!$ws->is_col_hidden(0), 'Regular column is not hidden'); +ok( $ws->is_col_hidden(1), 'Hidden column is hidden'); + +done_testing; |