diff options
author | Jesse Luehrs <doy@tozt.net> | 2015-03-15 01:14:28 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2015-03-15 01:14:28 -0400 |
commit | 5658f5368ac0fb4809cc34a30674a7f58fbda06f (patch) | |
tree | 08982cbed31f87ebc1107533156189e6db13b4f5 | |
parent | 26e4ae585b5a7a4a5af513d9dfb8b3b6509d7985 (diff) | |
parent | f32d2416c228eeafedcd7d77178c74efdc7e3884 (diff) | |
download | spreadsheet-parsexlsx-5658f5368ac0fb4809cc34a30674a7f58fbda06f.tar.gz spreadsheet-parsexlsx-5658f5368ac0fb4809cc34a30674a7f58fbda06f.zip |
Merge branch 'pull-27'
-rw-r--r-- | lib/Spreadsheet/ParseXLSX.pm | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/lib/Spreadsheet/ParseXLSX.pm b/lib/Spreadsheet/ParseXLSX.pm index fdaf2b7..7f9b4ef 100644 --- a/lib/Spreadsheet/ParseXLSX.pm +++ b/lib/Spreadsheet/ParseXLSX.pm @@ -121,7 +121,7 @@ sub _parse_workbook { $workbook->{SheetCount} = scalar(@sheets); my ($node) = $files->{workbook}->find_nodes('//workbookView'); - my $selected = $node->att('activeTab'); + my $selected = $node ? $node->att('activeTab') : undef; $workbook->{SelectedSheet} = defined($selected) ? 0+$selected : 0; return $workbook; @@ -158,8 +158,8 @@ sub _parse_sheet { $sheet->{MinRow} = $rmin; $sheet->{MinCol} = $cmin; - $sheet->{MaxRow} = $rmax; - $sheet->{MaxCol} = $cmax; + $sheet->{MaxRow} = $rmax ? $rmax : -1; + $sheet->{MaxCol} = $cmax ? $cmax : -1; $twig->purge; }, @@ -287,10 +287,18 @@ sub _parse_sheet { for my $cell ( $row_elt->children('c') ){ my ($row, $col) = $self->_cell_to_row_col($cell->att('r')); + $sheet->{MaxRow} = $row + if $sheet->{MaxRow} < $row; + $sheet->{MaxCol} = $col + if $sheet->{MaxCol} < $col; my $type = $cell->att('t') || 'n'; - my $val_xml = $type eq 'inlineStr' - ? $cell->first_child('is')->first_child('t') - : $cell->first_child('v'); + my $val_xml; + if ($type ne 'inlineStr') { + $val_xml = $cell->first_child('v'); + } + elsif (defined $cell->first_child('is')) { + $val_xml = ($cell->find_nodes('.//t'))[0]; + } my $val = $val_xml ? $val_xml->text : undef; my $long_type; @@ -813,7 +821,13 @@ sub _color { $color = '#' . substr($color_node->att('rgb'), 2, 6); } elsif (defined $color_node->att('theme')) { - $color = '#' . $colors->[$color_node->att('theme')]; + my $theme = $colors->[$color_node->att('theme')]; + if (defined $theme) { + $color = "#$theme"; + } + else { + return; + } } $color = $self->_apply_tint($color, $color_node->att('tint')) |