Skip to content

Commit

Permalink
worksheet: add extra test for sheet name quoting
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcnamara committed Jun 22, 2024
1 parent 38c4573 commit dbf86ef
Show file tree
Hide file tree
Showing 6 changed files with 273 additions and 0 deletions.
91 changes: 91 additions & 0 deletions t/regression/quote_name05.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
###############################################################################
#
# 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 = 'quote_name05.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.
#
use Excel::Writer::XLSX;

my $workbook = Excel::Writer::XLSX->new( $got_filename );
my $worksheet = $workbook->add_worksheet();
my $chart = $workbook->add_chart( type => 'column', embedded => 1 );

# For testing, copy the randomly generated axis ids in the target xlsx file.
$chart->{_axis_ids} = [ 54437760, 59195776 ];

my $data = [
[ 1, 2, 3, 4, 5 ],
[ 2, 4, 6, 8, 10 ],
[ 3, 6, 9, 12, 15 ],

];

$worksheet->write( 'A1', $data );
$worksheet->repeat_rows( 0, 1 );
$worksheet->set_portrait();
$worksheet->{_vertical_dpi} = 200;

$chart->add_series( values => [ 'Sheet1', 0, 4, 0, 0 ] );
$chart->add_series( values => [ 'Sheet1', 0, 4, 1, 1 ] );
$chart->add_series( values => [ 'Sheet1', 0, 4, 2, 2 ] );

$worksheet->insert_chart( 'E9', $chart );

$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__
91 changes: 91 additions & 0 deletions t/regression/quote_name06.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
###############################################################################
#
# 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 = 'quote_name06.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.
#
use Excel::Writer::XLSX;

my $workbook = Excel::Writer::XLSX->new( $got_filename );
my $worksheet = $workbook->add_worksheet(q{Sheet-1});
my $chart = $workbook->add_chart( type => 'column', embedded => 1 );

# For testing, copy the randomly generated axis ids in the target xlsx file.
$chart->{_axis_ids} = [ 62284544, 83429248 ];

my $data = [
[ 1, 2, 3, 4, 5 ],
[ 2, 4, 6, 8, 10 ],
[ 3, 6, 9, 12, 15 ],

];

$worksheet->write( 'A1', $data );
$worksheet->repeat_rows( 0, 1 );
$worksheet->set_portrait();
$worksheet->{_vertical_dpi} = 200;

$chart->add_series( values => [ q{Sheet-1}, 0, 4, 0, 0 ] );
$chart->add_series( values => [ q{Sheet-1}, 0, 4, 1, 1 ] );
$chart->add_series( values => [ q{Sheet-1}, 0, 4, 2, 2 ] );

$worksheet->insert_chart( 'E9', $chart );

$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__
91 changes: 91 additions & 0 deletions t/regression/quote_name07.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
###############################################################################
#
# 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 = 'quote_name07.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.
#
use Excel::Writer::XLSX;

my $workbook = Excel::Writer::XLSX->new( $got_filename );
my $worksheet = $workbook->add_worksheet(q{Sheet'1});
my $chart = $workbook->add_chart( type => 'column', embedded => 1 );

# For testing, copy the randomly generated axis ids in the target xlsx file.
$chart->{_axis_ids} = [ 48135552, 54701056 ];

my $data = [
[ 1, 2, 3, 4, 5 ],
[ 2, 4, 6, 8, 10 ],
[ 3, 6, 9, 12, 15 ],

];

$worksheet->write( 'A1', $data );
$worksheet->repeat_rows( 0, 1 );
$worksheet->set_portrait();
$worksheet->{_vertical_dpi} = 200;

$chart->add_series( values => [ q{Sheet'1}, 0, 4, 0, 0 ] );
$chart->add_series( values => [ q{Sheet'1}, 0, 4, 1, 1 ] );
$chart->add_series( values => [ q{Sheet'1}, 0, 4, 2, 2 ] );

$worksheet->insert_chart( 'E9', $chart );

$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/quote_name05.xlsx
Binary file not shown.
Binary file added t/regression/xlsx_files/quote_name06.xlsx
Binary file not shown.
Binary file added t/regression/xlsx_files/quote_name07.xlsx
Binary file not shown.

0 comments on commit dbf86ef

Please sign in to comment.