summaryrefslogtreecommitdiffstats
path: root/lib/Spreadsheet/ParseXLSX.pm
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-03-21 16:53:39 -0400
committerJesse Luehrs <doy@tozt.net>2014-03-21 16:57:41 -0400
commit30daf8b7d777faf5814a53c2e0501c0f0966a4a7 (patch)
tree6a26daf5401f8a80697845a6d68597dfb1a1b3fd /lib/Spreadsheet/ParseXLSX.pm
parentd999c50d9444a89e4746006a25f7cfe9b56cddca (diff)
downloadspreadsheet-parsexlsx-30daf8b7d777faf5814a53c2e0501c0f0966a4a7.tar.gz
spreadsheet-parsexlsx-30daf8b7d777faf5814a53c2e0501c0f0966a4a7.zip
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
Diffstat (limited to 'lib/Spreadsheet/ParseXLSX.pm')
-rw-r--r--lib/Spreadsheet/ParseXLSX.pm32
1 files changed, 21 insertions, 11 deletions
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');