From 8a787698efd28a9bec64b1e5d13a4670b1bc1779 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 29 Jul 2013 19:15:48 -0400 Subject: fix spreadsheets that have only a single cell (#2) --- lib/Spreadsheet/ParseXLSX.pm | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/Spreadsheet/ParseXLSX.pm b/lib/Spreadsheet/ParseXLSX.pm index d96d275..055bcba 100644 --- a/lib/Spreadsheet/ParseXLSX.pm +++ b/lib/Spreadsheet/ParseXLSX.pm @@ -126,9 +126,9 @@ sub _parse_sheet { # XXX need a fallback here, the dimension tag is optional my ($dimension) = $sheet_xml->find_nodes('//dimension'); - my ($topleft, $bottomright) = split ':', $dimension->att('ref'); - my ($rmin, $cmin) = $self->_cell_to_row_col($topleft); - my ($rmax, $cmax) = $self->_cell_to_row_col($bottomright); + my ($rmin, $cmin, $rmax, $cmax) = $self->_dimensions( + $dimension->att('ref') + ); $sheet->{MinRow} = $rmin; $sheet->{MinCol} = $cmin; @@ -552,6 +552,19 @@ sub _base_path_for { return join('/', @path) . '/'; } +sub _dimensions { + my $self = shift; + my ($dim) = @_; + + my ($topleft, $bottomright) = split ':', $dim; + $bottomright = $topleft unless defined $bottomright; + + my ($rmin, $cmin) = $self->_cell_to_row_col($topleft); + my ($rmax, $cmax) = $self->_cell_to_row_col($bottomright); + + return ($rmin, $cmin, $rmax, $cmax); +} + sub _cell_to_row_col { my $self = shift; my ($cell) = @_; -- cgit v1.2.3-54-g00ecf