From 48c05714c254df089e170c014661db9a4bc7d21d Mon Sep 17 00:00:00 2001 From: Steve Simms Date: Thu, 29 Oct 2015 16:05:14 -0400 Subject: Check to see if rows and columns are hidden --- lib/Spreadsheet/ParseXLSX.pm | 6 ++++++ t/data/hidden-row-and-column.xlsx | Bin 0 -> 7467 bytes t/hidden-row-and-column.t | 17 +++++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 t/data/hidden-row-and-column.xlsx create mode 100644 t/hidden-row-and-column.t 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 new file mode 100644 index 0000000..4d4bac4 Binary files /dev/null and b/t/data/hidden-row-and-column.xlsx differ 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; -- cgit v1.2.3-54-g00ecf