|
| 1 | +############################################################################### |
| 2 | +# |
| 3 | +# Tests for Excel::Writer::XLSX::Worksheet methods. |
| 4 | +# |
| 5 | +# Copyright 2000-2024, John McNamara, jmcnamara@cpan.org |
| 6 | +# |
| 7 | +# SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later |
| 8 | +# |
| 9 | + |
| 10 | +use lib 't/lib'; |
| 11 | +use TestFunctions qw(_expected_to_aref _got_to_aref _is_deep_diff _new_worksheet); |
| 12 | +use strict; |
| 13 | +use warnings; |
| 14 | + |
| 15 | +use Test::More tests => 1; |
| 16 | + |
| 17 | +############################################################################### |
| 18 | +# |
| 19 | +# Tests setup. |
| 20 | +# |
| 21 | +my $expected; |
| 22 | +my $got; |
| 23 | +my $caption; |
| 24 | +my $worksheet; |
| 25 | + |
| 26 | + |
| 27 | +############################################################################### |
| 28 | +# |
| 29 | +# Test the _assemble_xml_file() method. |
| 30 | +# |
| 31 | +# Test conditional formats. |
| 32 | +# |
| 33 | +$caption = " \tWorksheet: _assemble_xml_file()"; |
| 34 | + |
| 35 | +$worksheet = _new_worksheet(\$got); |
| 36 | + |
| 37 | +$worksheet->select(); |
| 38 | + |
| 39 | +# Start test code. |
| 40 | +$worksheet->conditional_formatting( 'A1', |
| 41 | + { |
| 42 | + type => 'cell', |
| 43 | + format => undef, |
| 44 | + criteria => '==', |
| 45 | + value => 'Test A2', |
| 46 | + } |
| 47 | +); |
| 48 | +# End test code. |
| 49 | + |
| 50 | +$worksheet->_assemble_xml_file(); |
| 51 | + |
| 52 | +$expected = _expected_to_aref(); |
| 53 | +$got = _got_to_aref( $got ); |
| 54 | + |
| 55 | +_is_deep_diff( $got, $expected, $caption ); |
| 56 | + |
| 57 | +__DATA__ |
| 58 | +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> |
| 59 | +<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"> |
| 60 | + <dimension ref="A1"/> |
| 61 | + <sheetViews> |
| 62 | + <sheetView tabSelected="1" workbookViewId="0"/> |
| 63 | + </sheetViews> |
| 64 | + <sheetFormatPr defaultRowHeight="15"/> |
| 65 | + <sheetData/> |
| 66 | + <conditionalFormatting sqref="A1"> |
| 67 | + <cfRule type="cellIs" priority="1" operator="equal"> |
| 68 | + <formula>"Test A2"</formula> |
| 69 | + </cfRule> |
| 70 | + </conditionalFormatting> |
| 71 | + <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/> |
| 72 | +</worksheet> |
0 commit comments