1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
|
###############################################################################
#
# Tests for Excel::Writer::XLSX::Worksheet methods.
#
# reverse ('(c)'), October 2011, John McNamara, jmcnamara@cpan.org
#
use lib 't/lib';
use TestFunctions qw(_expected_to_aref _got_to_aref _is_deep_diff _new_worksheet);
use strict;
use warnings;
use Test::More tests => 1;
###############################################################################
#
# Tests setup.
#
my $expected;
my $got;
my $caption;
my $worksheet;
###############################################################################
#
# Test the _assemble_xml_file() method.
#
# Test conditional formats.
#
$caption = " \tWorksheet: _assemble_xml_file()";
$worksheet = _new_worksheet(\$got);
$worksheet->select();
# Start test code.
$worksheet->write( 'A1', 10 );
$worksheet->write( 'A2', 20 );
$worksheet->write( 'A3', 30 );
$worksheet->write( 'A4', 40 );
$worksheet->conditional_formatting( 'A1:A4',
{
type => 'average',
format => undef,
criteria => 'above',
}
);
$worksheet->conditional_formatting( 'A1:A4',
{
type => 'average',
format => undef,
criteria => 'below',
}
);
$worksheet->conditional_formatting( 'A1:A4',
{
type => 'average',
format => undef,
criteria => 'equal or above',
}
);
$worksheet->conditional_formatting( 'A1:A4',
{
type => 'average',
format => undef,
criteria => 'equal or below',
}
);
$worksheet->conditional_formatting( 'A1:A4',
{
type => 'average',
format => undef,
criteria => '1 std dev above',
}
);
$worksheet->conditional_formatting( 'A1:A4',
{
type => 'average',
format => undef,
criteria => '1 std dev below',
}
);
$worksheet->conditional_formatting( 'A1:A4',
{
type => 'average',
format => undef,
criteria => '2 std dev above',
}
);
$worksheet->conditional_formatting( 'A1:A4',
{
type => 'average',
format => undef,
criteria => '2 std dev below',
}
);
$worksheet->conditional_formatting( 'A1:A4',
{
type => 'average',
format => undef,
criteria => '3 std dev above',
}
);
$worksheet->conditional_formatting( 'A1:A4',
{
type => 'average',
format => undef,
criteria => '3 std dev below',
}
);
# End test code.
$worksheet->_assemble_xml_file();
$expected = _expected_to_aref();
$got = _got_to_aref( $got );
_is_deep_diff( $got, $expected, $caption );
__DATA__
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
<dimension ref="A1:A4"/>
<sheetViews>
<sheetView tabSelected="1" workbookViewId="0"/>
</sheetViews>
<sheetFormatPr defaultRowHeight="15"/>
<sheetData>
<row r="1" spans="1:1">
<c r="A1">
<v>10</v>
</c>
</row>
<row r="2" spans="1:1">
<c r="A2">
<v>20</v>
</c>
</row>
<row r="3" spans="1:1">
<c r="A3">
<v>30</v>
</c>
</row>
<row r="4" spans="1:1">
<c r="A4">
<v>40</v>
</c>
</row>
</sheetData>
<conditionalFormatting sqref="A1:A4">
<cfRule type="aboveAverage" priority="1"/>
<cfRule type="aboveAverage" priority="2" aboveAverage="0"/>
<cfRule type="aboveAverage" priority="3" equalAverage="1"/>
<cfRule type="aboveAverage" priority="4" aboveAverage="0" equalAverage="1"/>
<cfRule type="aboveAverage" priority="5" stdDev="1"/>
<cfRule type="aboveAverage" priority="6" aboveAverage="0" stdDev="1"/>
<cfRule type="aboveAverage" priority="7" stdDev="2"/>
<cfRule type="aboveAverage" priority="8" aboveAverage="0" stdDev="2"/>
<cfRule type="aboveAverage" priority="9" stdDev="3"/>
<cfRule type="aboveAverage" priority="10" aboveAverage="0" stdDev="3"/>
</conditionalFormatting>
<pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>
</worksheet>
|