From 30daf8b7d777faf5814a53c2e0501c0f0966a4a7 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 21 Mar 2014 16:53:39 -0400 Subject: fix incompatibility with newer Spreadsheet::ParseExcel (fixes #22) in https://rt.cpan.org/Public/Bug/Display.html?id=93065, Spreadsheet::ParseExcel decided to start treating 'auto' colors as black instead of white, but this isn't correct for fill colors, so we have to correct for that --- Changes | 2 ++ lib/Spreadsheet/ParseXLSX.pm | 32 +++++++++++++++++++++----------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/Changes b/Changes index 5740261..c919795 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,8 @@ Revision history for Spreadsheet-ParseXLSX {{$NEXT}} + - fix incompatibility with newer Spreadsheet::ParseExcel (reported by + dsteinbrunner, #22) 0.13 2014-01-29 - support locked and hidden cells (Tux, #15) diff --git a/lib/Spreadsheet/ParseXLSX.pm b/lib/Spreadsheet/ParseXLSX.pm index 1b2ddda..ccdfd5d 100644 --- a/lib/Spreadsheet/ParseXLSX.pm +++ b/lib/Spreadsheet/ParseXLSX.pm @@ -6,7 +6,7 @@ use warnings; use Archive::Zip; use Graphics::ColorUtils 'rgb2hls', 'hls2rgb'; use Scalar::Util 'openhandle'; -use Spreadsheet::ParseExcel 0.55; +use Spreadsheet::ParseExcel 0.61; use XML::Twig; =head1 SYNOPSIS @@ -379,8 +379,8 @@ sub _parse_styles { my @fills = map { [ $fill{$_->att('patternType')}, - $self->_color($workbook->{Color}, $_->first_child('fgColor')), - $self->_color($workbook->{Color}, $_->first_child('bgColor')), + $self->_color($workbook->{Color}, $_->first_child('fgColor'), 1), + $self->_color($workbook->{Color}, $_->first_child('bgColor'), 1), ] } $styles->find_nodes('//fills/fill/patternFill'); @@ -671,17 +671,27 @@ sub _cell_to_row_col { sub _color { my $self = shift; - my ($colors, $color_node) = @_; + my ($colors, $color_node, $fill) = @_; my $color; if ($color_node && !$color_node->att('auto')) { - $color = '#' . Spreadsheet::ParseExcel->ColorIdxToRGB( - $color_node->att('indexed') - ) if defined $color_node->att('indexed'); - $color = '#' . substr($color_node->att('rgb'), 2, 6) - if defined $color_node->att('rgb'); - $color = '#' . $colors->[$color_node->att('theme')] - if defined $color_node->att('theme'); + if (defined $color_node->att('indexed')) { + # see https://rt.cpan.org/Public/Bug/Display.html?id=93065 + if ($fill && $color_node->att('indexed') == 64) { + return '#FFFFFF'; + } + else { + $color = '#' . Spreadsheet::ParseExcel->ColorIdxToRGB( + $color_node->att('indexed') + ); + } + } + elsif (defined $color_node->att('rgb')) { + $color = '#' . substr($color_node->att('rgb'), 2, 6); + } + elsif (defined $color_node->att('theme')) { + $color = '#' . $colors->[$color_node->att('theme')]; + } $color = $self->_apply_tint($color, $color_node->att('tint')) if $color_node->att('tint'); -- cgit v1.2.3-54-g00ecf From a2d2c0c6152b92f315ae5ebfe2f4aa025323a576 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 3 Apr 2014 10:19:42 -0400 Subject: note the XML::Twig bug (fixes #20) --- lib/Spreadsheet/ParseXLSX.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/Spreadsheet/ParseXLSX.pm b/lib/Spreadsheet/ParseXLSX.pm index ccdfd5d..d5f7781 100644 --- a/lib/Spreadsheet/ParseXLSX.pm +++ b/lib/Spreadsheet/ParseXLSX.pm @@ -752,6 +752,18 @@ were explicitly provided when the spreadsheet was written. =over 4 +=item Large spreadsheets may cause segfaults on perl 5.14 and earlier + +This module internally uses XML::Twig, which makes it potentially subject to +L +on perl versions 5.14 and below (the underlying bug with perl weak references +was fixed in perl 5.15.5). The larger and more complex the spreadsheet, the +more likely to be affected, but the actual size at which it segfaults is +platform dependent. On a 64-bit perl with 7.6gb memory, it was seen on +spreadsheets about 300mb and above. You can work around this adding +C to your code before parsing the spreadsheet, +although this may have other consequences such as memory leaks. + =item Worksheets without the C tag are not supported =item Intra-cell formatting is discarded -- cgit v1.2.3-54-g00ecf From 8d5eb1ae9dfdf01ba89ca807f947f16f9bfc02a1 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 3 Apr 2014 12:56:06 -0400 Subject: changelog --- Changes | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changes b/Changes index c919795..ea9e86a 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,8 @@ Revision history for Spreadsheet-ParseXLSX {{$NEXT}} + +0.14 2014-04-03 - fix incompatibility with newer Spreadsheet::ParseExcel (reported by dsteinbrunner, #22) -- cgit v1.2.3-54-g00ecf