Skip to content

Commit

Permalink
format: fix for html style border colors
Browse files Browse the repository at this point in the history
Fixes #302
  • Loading branch information
jmcnamara committed Aug 2, 2024
1 parent 3e64c89 commit 7c2c929
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Excel/Writer/XLSX/Package/Styles.pm
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ sub _write_sub_border {

$self->xml_start_tag( $type, @attributes );

if ( $color && $color != 64 ) {
if ( $color && $color ne "64" ) {
$color = $self->_get_palette_color( $color );

$self->xml_empty_tag( 'color', 'rgb' => $color );
Expand Down
71 changes: 71 additions & 0 deletions t/regression/format25.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
###############################################################################
#
# Tests the output of Excel::Writer::XLSX against Excel generated files.
#
# Copyright 2000-2024, John McNamara, [email protected]
#
# SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later
#

use lib 't/lib';
use TestFunctions qw(_compare_xlsx_files _is_deep_diff);
use strict;
use warnings;

use Test::More tests => 1;

###############################################################################
#
# Tests setup.
#
my $filename = 'format25.xlsx';
my $dir = 't/regression/';
my $got_filename = $dir . "ewx_$filename";
my $exp_filename = $dir . 'xlsx_files/' . $filename;

my $ignore_members = [];
my $ignore_elements = {};


###############################################################################
#
# Test the creation of a simple Excel::Writer::XLSX file with automatic color.
#
use Excel::Writer::XLSX;

my $workbook = Excel::Writer::XLSX->new( $got_filename );
my $worksheet = $workbook->add_worksheet();

my $format1 = $workbook->add_format(
border_color => '#FF9966',
border => 1,
);

$worksheet->write( 2, 2, '', $format1 );

$workbook->close();


###############################################################################
#
# Compare the generated and existing Excel files.
#

my ( $got, $expected, $caption ) = _compare_xlsx_files(

$got_filename,
$exp_filename,
$ignore_members,
$ignore_elements,
);

_is_deep_diff( $got, $expected, $caption );


###############################################################################
#
# Cleanup.
#
unlink $got_filename;

__END__
Binary file added t/regression/xlsx_files/format25.xlsx
Binary file not shown.

0 comments on commit 7c2c929

Please sign in to comment.