write_xlsx 0.90.0 → 0.97.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Changes +37 -0
- data/README.md +1 -1
- data/examples/a_simple.rb +1 -6
- data/examples/conditional_format.rb +73 -46
- data/examples/demo.rb +1 -7
- data/examples/hyperlink1.rb +4 -11
- data/lib/write_xlsx/chart.rb +81 -205
- data/lib/write_xlsx/chart/axis.rb +2 -2
- data/lib/write_xlsx/chart/caption.rb +3 -1
- data/lib/write_xlsx/chart/pie.rb +2 -0
- data/lib/write_xlsx/chart/series.rb +11 -7
- data/lib/write_xlsx/format.rb +15 -11
- data/lib/write_xlsx/package/conditional_format.rb +351 -38
- data/lib/write_xlsx/package/content_types.rb +10 -0
- data/lib/write_xlsx/package/custom.rb +125 -0
- data/lib/write_xlsx/package/packager.rb +26 -0
- data/lib/write_xlsx/package/styles.rb +53 -21
- data/lib/write_xlsx/package/table.rb +11 -4
- data/lib/write_xlsx/utility.rb +234 -34
- data/lib/write_xlsx/version.rb +1 -1
- data/lib/write_xlsx/workbook.rb +88 -1
- data/lib/write_xlsx/worksheet.rb +247 -23
- data/test/helper.rb +6 -1
- data/test/regression/_test_hyperlink31.rb +26 -0
- data/test/regression/images/zero_dpi.jpg +0 -0
- data/test/regression/test_chart_bar08.rb +3 -0
- data/test/regression/test_chart_bar11.rb +3 -0
- data/test/regression/test_chart_bar14.rb +3 -0
- data/test/regression/test_chart_chartarea05.rb +16 -17
- data/test/regression/test_chart_chartarea06.rb +49 -0
- data/test/regression/test_chart_data_labels25.rb +61 -0
- data/test/regression/test_chart_format26.rb +48 -0
- data/test/regression/test_chart_format27.rb +58 -0
- data/test/regression/test_chart_format28.rb +52 -0
- data/test/regression/test_chart_format29.rb +59 -0
- data/test/regression/test_chart_format30.rb +53 -0
- data/test/regression/test_chart_format31.rb +60 -0
- data/test/regression/test_chart_table03.rb +56 -0
- data/test/regression/test_cond_format14.rb +42 -0
- data/test/regression/test_cond_format15.rb +53 -0
- data/test/regression/test_cond_format16.rb +53 -0
- data/test/regression/test_cond_format17.rb +37 -0
- data/test/regression/test_cond_format18.rb +136 -0
- data/test/regression/test_date_1904_01.rb +1 -1
- data/test/regression/test_escapes04.rb +3 -0
- data/test/regression/test_escapes05.rb +3 -0
- data/test/regression/test_escapes07.rb +3 -0
- data/test/regression/test_escapes08.rb +3 -0
- data/test/regression/test_hyperlink01.rb +3 -0
- data/test/regression/test_hyperlink02.rb +3 -0
- data/test/regression/test_hyperlink03.rb +4 -0
- data/test/regression/test_hyperlink04.rb +3 -0
- data/test/regression/test_hyperlink05.rb +3 -0
- data/test/regression/test_hyperlink06.rb +3 -0
- data/test/regression/test_hyperlink07.rb +3 -0
- data/test/regression/test_hyperlink08.rb +3 -0
- data/test/regression/test_hyperlink09.rb +3 -0
- data/test/regression/test_hyperlink10.rb +3 -0
- data/test/regression/test_hyperlink11.rb +3 -0
- data/test/regression/test_hyperlink12.rb +3 -0
- data/test/regression/test_hyperlink13.rb +3 -0
- data/test/regression/test_hyperlink14.rb +3 -0
- data/test/regression/test_hyperlink15.rb +3 -0
- data/test/regression/test_hyperlink16.rb +3 -0
- data/test/regression/test_hyperlink17.rb +3 -0
- data/test/regression/test_hyperlink18.rb +3 -0
- data/test/regression/test_hyperlink20.rb +3 -0
- data/test/regression/test_hyperlink21.rb +3 -0
- data/test/regression/test_hyperlink22.rb +3 -0
- data/test/regression/test_hyperlink23.rb +3 -0
- data/test/regression/test_hyperlink24.rb +3 -0
- data/test/regression/test_hyperlink25.rb +3 -0
- data/test/regression/test_hyperlink26.rb +3 -0
- data/test/regression/test_hyperlink27.rb +3 -0
- data/test/regression/test_hyperlink28.rb +50 -0
- data/test/regression/test_hyperlink29.rb +27 -0
- data/test/regression/test_hyperlink30.rb +36 -0
- data/test/regression/test_image35.rb +26 -0
- data/test/regression/test_properties01.rb +1 -4
- data/test/regression/test_properties02.rb +1 -4
- data/test/regression/test_properties03.rb +26 -0
- data/test/regression/test_properties04.rb +61 -0
- data/test/regression/test_properties05.rb +30 -0
- data/test/regression/test_table03.rb +3 -0
- data/test/regression/test_table04.rb +3 -0
- data/test/regression/test_table05.rb +3 -0
- data/test/regression/test_table06.rb +3 -0
- data/test/regression/test_table20.rb +34 -0
- data/test/regression/test_table21.rb +36 -0
- data/test/regression/test_table22.rb +32 -0
- data/test/regression/xlsx_files/chart_chartarea05.xlsx +0 -0
- data/test/regression/xlsx_files/chart_chartarea06.xlsx +0 -0
- data/test/regression/xlsx_files/chart_data_labels25.xlsx +0 -0
- data/test/regression/xlsx_files/chart_format26.xlsx +0 -0
- data/test/regression/xlsx_files/chart_format27.xlsx +0 -0
- data/test/regression/xlsx_files/chart_format28.xlsx +0 -0
- data/test/regression/xlsx_files/chart_format29.xlsx +0 -0
- data/test/regression/xlsx_files/chart_format30.xlsx +0 -0
- data/test/regression/xlsx_files/chart_format31.xlsx +0 -0
- data/test/regression/xlsx_files/chart_table03.xlsx +0 -0
- data/test/regression/xlsx_files/cond_format14.xlsx +0 -0
- data/test/regression/xlsx_files/cond_format15.xlsx +0 -0
- data/test/regression/xlsx_files/cond_format16.xlsx +0 -0
- data/test/regression/xlsx_files/cond_format17.xlsx +0 -0
- data/test/regression/xlsx_files/cond_format18.xlsx +0 -0
- data/test/regression/xlsx_files/date_1904_01.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink28.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink29.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink30.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink31.xlsx +0 -0
- data/test/regression/xlsx_files/image35.xlsx +0 -0
- data/test/regression/xlsx_files/properties03.xlsx +0 -0
- data/test/regression/xlsx_files/properties04.xlsx +0 -0
- data/test/regression/xlsx_files/properties05.xlsx +0 -0
- data/test/regression/xlsx_files/table21.xlsx +0 -0
- data/test/regression/xlsx_files/table22.xlsx +0 -0
- data/test/workbook/test_write_workbook_view.rb +81 -0
- data/test/worksheet/test_cond_format_22.rb +266 -0
- data/test/worksheet/test_cond_format_23.rb +242 -0
- data/test/worksheet/test_cond_format_24.rb +303 -0
- data/test/worksheet/test_data_bar_01.rb +53 -0
- data/test/worksheet/test_data_bar_02.rb +79 -0
- data/test/worksheet/test_data_bar_03.rb +147 -0
- data/test/worksheet/test_data_bar_04.rb +145 -0
- data/test/worksheet/test_data_bar_05.rb +147 -0
- data/test/worksheet/test_data_bar_06.rb +145 -0
- data/test/worksheet/test_data_bar_07.rb +146 -0
- data/test/worksheet/test_data_bar_08.rb +54 -0
- data/test/worksheet/test_data_bar_09.rb +80 -0
- data/test/worksheet/test_data_bar_10.rb +165 -0
- data/test/worksheet/test_data_bar_11.rb +167 -0
- data/test/worksheet/test_data_bar_12.rb +104 -0
- data/test/worksheet/test_write_data_validation_02.rb +27 -0
- metadata +135 -2
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
require 'write_xlsx'
|
|
4
|
+
require 'stringio'
|
|
5
|
+
|
|
6
|
+
class TestCondFormat22 < Minitest::Test
|
|
7
|
+
def setup
|
|
8
|
+
@workbook = WriteXLSX.new(StringIO.new)
|
|
9
|
+
@worksheet = @workbook.add_worksheet('')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
###############################################################################
|
|
13
|
+
#
|
|
14
|
+
# Tests for Excel::Writer::XLSX::Worksheet methods.
|
|
15
|
+
#
|
|
16
|
+
|
|
17
|
+
###############################################################################
|
|
18
|
+
#
|
|
19
|
+
# Test the _assemble_xml_file() method.
|
|
20
|
+
#
|
|
21
|
+
# Test conditional formats.
|
|
22
|
+
#
|
|
23
|
+
def test_conditional_formats
|
|
24
|
+
@worksheet.select
|
|
25
|
+
|
|
26
|
+
# Start test code.
|
|
27
|
+
@worksheet.write('A1', 1)
|
|
28
|
+
@worksheet.write('A2', 2)
|
|
29
|
+
@worksheet.write('A3', 3)
|
|
30
|
+
@worksheet.write('A4', 4)
|
|
31
|
+
@worksheet.write('A5', 5)
|
|
32
|
+
@worksheet.write('A6', 6)
|
|
33
|
+
@worksheet.write('A7', 7)
|
|
34
|
+
@worksheet.write('A8', 8)
|
|
35
|
+
@worksheet.write('A9', 9)
|
|
36
|
+
|
|
37
|
+
@worksheet.write('A12', 75)
|
|
38
|
+
|
|
39
|
+
@worksheet.conditional_formatting(
|
|
40
|
+
'A1',
|
|
41
|
+
{
|
|
42
|
+
:type => 'icon_set',
|
|
43
|
+
:icon_style => '3_arrows',
|
|
44
|
+
:reverse_icons => 1
|
|
45
|
+
}
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
@worksheet.conditional_formatting(
|
|
49
|
+
'A2',
|
|
50
|
+
{
|
|
51
|
+
:type => 'icon_set',
|
|
52
|
+
:icon_style => '3_flags',
|
|
53
|
+
:icons_only => 1
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
@worksheet.conditional_formatting(
|
|
58
|
+
'A3',
|
|
59
|
+
{
|
|
60
|
+
:type => 'icon_set',
|
|
61
|
+
:icon_style => '3_traffic_lights_rimmed',
|
|
62
|
+
:icons_only => 1,
|
|
63
|
+
:reverse_icons => 1
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
@worksheet.conditional_formatting(
|
|
68
|
+
'A4',
|
|
69
|
+
{
|
|
70
|
+
:type => 'icon_set',
|
|
71
|
+
:icon_style => '3_symbols_circled',
|
|
72
|
+
:icons => [
|
|
73
|
+
{:value => 80},
|
|
74
|
+
{:value => 20}
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
@worksheet.conditional_formatting(
|
|
80
|
+
'A5',
|
|
81
|
+
{
|
|
82
|
+
:type => 'icon_set',
|
|
83
|
+
:icon_style => '4_arrows',
|
|
84
|
+
:icons => [
|
|
85
|
+
{:criteria => '>'},
|
|
86
|
+
{:criteria => '>'},
|
|
87
|
+
{:criteria => '>'}
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
@worksheet.conditional_formatting(
|
|
93
|
+
'A6',
|
|
94
|
+
{
|
|
95
|
+
:type => 'icon_set',
|
|
96
|
+
:icon_style => '4_red_to_black',
|
|
97
|
+
:icons => [
|
|
98
|
+
{:criteria => '>=', :type => 'number', :value => 90},
|
|
99
|
+
{:criteria => '<', :type => 'percentile', :value => 50},
|
|
100
|
+
{:criteria => '<=', :type => 'percent', :value => 25}
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
@worksheet.conditional_formatting(
|
|
106
|
+
'A7',
|
|
107
|
+
{
|
|
108
|
+
:type => 'icon_set',
|
|
109
|
+
:icon_style => '4_traffic_lights',
|
|
110
|
+
:icons => [ {:value => '=$A$12'} ]
|
|
111
|
+
}
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
@worksheet.conditional_formatting(
|
|
115
|
+
'A8',
|
|
116
|
+
{
|
|
117
|
+
:type => 'icon_set',
|
|
118
|
+
:icon_style => '5_arrows_gray',
|
|
119
|
+
:icons => [
|
|
120
|
+
{:type => 'formula', :value => '=$A$12'}
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
@worksheet.conditional_formatting(
|
|
126
|
+
'A9',
|
|
127
|
+
{
|
|
128
|
+
:type => 'icon_set',
|
|
129
|
+
:icon_style => '5_quarters',
|
|
130
|
+
:icons => [
|
|
131
|
+
{:type => 'percentile', :value => 70},
|
|
132
|
+
{:type => 'percentile', :value => 50},
|
|
133
|
+
{:type => 'percentile', :value => 30},
|
|
134
|
+
{:type => 'percentile', :value => 10},
|
|
135
|
+
{:type => 'percentile', :value => -1}
|
|
136
|
+
],
|
|
137
|
+
:reverse_icons => 1
|
|
138
|
+
}
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
# End test code.
|
|
142
|
+
|
|
143
|
+
@worksheet.assemble_xml_file
|
|
144
|
+
result = got_to_array(@worksheet.instance_variable_get(:@writer).string)
|
|
145
|
+
|
|
146
|
+
expected = expected_to_array(expected_xml)
|
|
147
|
+
assert_equal(expected, result)
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def expected_xml
|
|
151
|
+
<<EOS
|
|
152
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
153
|
+
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
|
|
154
|
+
<dimension ref="A1:A12"/>
|
|
155
|
+
<sheetViews>
|
|
156
|
+
<sheetView tabSelected="1" workbookViewId="0"/>
|
|
157
|
+
</sheetViews>
|
|
158
|
+
<sheetFormatPr defaultRowHeight="15"/>
|
|
159
|
+
<sheetData>
|
|
160
|
+
<row r="1" spans="1:1">
|
|
161
|
+
<c r="A1">
|
|
162
|
+
<v>1</v>
|
|
163
|
+
</c>
|
|
164
|
+
</row>
|
|
165
|
+
<row r="2" spans="1:1">
|
|
166
|
+
<c r="A2">
|
|
167
|
+
<v>2</v>
|
|
168
|
+
</c>
|
|
169
|
+
</row>
|
|
170
|
+
<row r="3" spans="1:1">
|
|
171
|
+
<c r="A3">
|
|
172
|
+
<v>3</v>
|
|
173
|
+
</c>
|
|
174
|
+
</row>
|
|
175
|
+
<row r="4" spans="1:1">
|
|
176
|
+
<c r="A4">
|
|
177
|
+
<v>4</v>
|
|
178
|
+
</c>
|
|
179
|
+
</row>
|
|
180
|
+
<row r="5" spans="1:1">
|
|
181
|
+
<c r="A5">
|
|
182
|
+
<v>5</v>
|
|
183
|
+
</c>
|
|
184
|
+
</row>
|
|
185
|
+
<row r="6" spans="1:1">
|
|
186
|
+
<c r="A6">
|
|
187
|
+
<v>6</v>
|
|
188
|
+
</c>
|
|
189
|
+
</row>
|
|
190
|
+
<row r="7" spans="1:1">
|
|
191
|
+
<c r="A7">
|
|
192
|
+
<v>7</v>
|
|
193
|
+
</c>
|
|
194
|
+
</row>
|
|
195
|
+
<row r="8" spans="1:1">
|
|
196
|
+
<c r="A8">
|
|
197
|
+
<v>8</v>
|
|
198
|
+
</c>
|
|
199
|
+
</row>
|
|
200
|
+
<row r="9" spans="1:1">
|
|
201
|
+
<c r="A9">
|
|
202
|
+
<v>9</v>
|
|
203
|
+
</c>
|
|
204
|
+
</row>
|
|
205
|
+
<row r="12" spans="1:1">
|
|
206
|
+
<c r="A12">
|
|
207
|
+
<v>75</v>
|
|
208
|
+
</c>
|
|
209
|
+
</row>
|
|
210
|
+
</sheetData>
|
|
211
|
+
<conditionalFormatting sqref="A1">
|
|
212
|
+
<cfRule type="iconSet" priority="1">
|
|
213
|
+
<iconSet iconSet="3Arrows" reverse="1">
|
|
214
|
+
<cfvo type="percent" val="0"/>
|
|
215
|
+
<cfvo type="percent" val="33"/>
|
|
216
|
+
<cfvo type="percent" val="67"/>
|
|
217
|
+
</iconSet>
|
|
218
|
+
</cfRule>
|
|
219
|
+
</conditionalFormatting>
|
|
220
|
+
<conditionalFormatting sqref="A2">
|
|
221
|
+
<cfRule type="iconSet" priority="2">
|
|
222
|
+
<iconSet iconSet="3Flags" showValue="0">
|
|
223
|
+
<cfvo type="percent" val="0"/>
|
|
224
|
+
<cfvo type="percent" val="33"/>
|
|
225
|
+
<cfvo type="percent" val="67"/>
|
|
226
|
+
</iconSet>
|
|
227
|
+
</cfRule>
|
|
228
|
+
</conditionalFormatting>
|
|
229
|
+
<conditionalFormatting sqref="A3">
|
|
230
|
+
<cfRule type="iconSet" priority="3">
|
|
231
|
+
<iconSet iconSet="3TrafficLights2" showValue="0" reverse="1">
|
|
232
|
+
<cfvo type="percent" val="0"/>
|
|
233
|
+
<cfvo type="percent" val="33"/>
|
|
234
|
+
<cfvo type="percent" val="67"/>
|
|
235
|
+
</iconSet>
|
|
236
|
+
</cfRule>
|
|
237
|
+
</conditionalFormatting>
|
|
238
|
+
<conditionalFormatting sqref="A4">
|
|
239
|
+
<cfRule type="iconSet" priority="4">
|
|
240
|
+
<iconSet iconSet="3Symbols">
|
|
241
|
+
<cfvo type="percent" val="0"/>
|
|
242
|
+
<cfvo type="percent" val="20"/>
|
|
243
|
+
<cfvo type="percent" val="80"/>
|
|
244
|
+
</iconSet>
|
|
245
|
+
</cfRule>
|
|
246
|
+
</conditionalFormatting>
|
|
247
|
+
<conditionalFormatting sqref="A5">
|
|
248
|
+
<cfRule type="iconSet" priority="5">
|
|
249
|
+
<iconSet iconSet="4Arrows">
|
|
250
|
+
<cfvo type="percent" val="0"/>
|
|
251
|
+
<cfvo type="percent" val="25" gte="0"/>
|
|
252
|
+
<cfvo type="percent" val="50" gte="0"/>
|
|
253
|
+
<cfvo type="percent" val="75" gte="0"/>
|
|
254
|
+
</iconSet>
|
|
255
|
+
</cfRule>
|
|
256
|
+
</conditionalFormatting>
|
|
257
|
+
<conditionalFormatting sqref="A6">
|
|
258
|
+
<cfRule type="iconSet" priority="6">
|
|
259
|
+
<iconSet iconSet="4RedToBlack">
|
|
260
|
+
<cfvo type="percent" val="0"/>
|
|
261
|
+
<cfvo type="percent" val="25"/>
|
|
262
|
+
<cfvo type="percentile" val="50"/>
|
|
263
|
+
<cfvo type="num" val="90"/>
|
|
264
|
+
</iconSet>
|
|
265
|
+
</cfRule>
|
|
266
|
+
</conditionalFormatting>
|
|
267
|
+
<conditionalFormatting sqref="A7">
|
|
268
|
+
<cfRule type="iconSet" priority="7">
|
|
269
|
+
<iconSet iconSet="4TrafficLights">
|
|
270
|
+
<cfvo type="percent" val="0"/>
|
|
271
|
+
<cfvo type="percent" val="25"/>
|
|
272
|
+
<cfvo type="percent" val="50"/>
|
|
273
|
+
<cfvo type="percent" val="$A$12"/>
|
|
274
|
+
</iconSet>
|
|
275
|
+
</cfRule>
|
|
276
|
+
</conditionalFormatting>
|
|
277
|
+
<conditionalFormatting sqref="A8">
|
|
278
|
+
<cfRule type="iconSet" priority="8">
|
|
279
|
+
<iconSet iconSet="5ArrowsGray">
|
|
280
|
+
<cfvo type="percent" val="0"/>
|
|
281
|
+
<cfvo type="percent" val="20"/>
|
|
282
|
+
<cfvo type="percent" val="40"/>
|
|
283
|
+
<cfvo type="percent" val="60"/>
|
|
284
|
+
<cfvo type="formula" val="$A$12"/>
|
|
285
|
+
</iconSet>
|
|
286
|
+
</cfRule>
|
|
287
|
+
</conditionalFormatting>
|
|
288
|
+
<conditionalFormatting sqref="A9">
|
|
289
|
+
<cfRule type="iconSet" priority="9">
|
|
290
|
+
<iconSet iconSet="5Quarters" reverse="1">
|
|
291
|
+
<cfvo type="percent" val="0"/>
|
|
292
|
+
<cfvo type="percentile" val="10"/>
|
|
293
|
+
<cfvo type="percentile" val="30"/>
|
|
294
|
+
<cfvo type="percentile" val="50"/>
|
|
295
|
+
<cfvo type="percentile" val="70"/>
|
|
296
|
+
</iconSet>
|
|
297
|
+
</cfRule>
|
|
298
|
+
</conditionalFormatting>
|
|
299
|
+
<pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>
|
|
300
|
+
</worksheet>
|
|
301
|
+
EOS
|
|
302
|
+
end
|
|
303
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
|
|
4
|
+
class TestWorksheetDataBar01 < Minitest::Test
|
|
5
|
+
def setup
|
|
6
|
+
@workbook = WriteXLSX.new(StringIO.new)
|
|
7
|
+
@worksheet = @workbook.add_worksheet('')
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
###############################################################################
|
|
11
|
+
#
|
|
12
|
+
# Tests for WriteXLSX::Worksheet methods.
|
|
13
|
+
#
|
|
14
|
+
#
|
|
15
|
+
def test_data_bar_01
|
|
16
|
+
@worksheet.select
|
|
17
|
+
|
|
18
|
+
@worksheet.conditional_formatting(
|
|
19
|
+
'A1',
|
|
20
|
+
:type => 'data_bar'
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
@worksheet.assemble_xml_file
|
|
24
|
+
result = got_to_array(@worksheet.instance_variable_get(:@writer).string)
|
|
25
|
+
|
|
26
|
+
expected = expected_to_array(expected_xml)
|
|
27
|
+
assert_equal(expected, result)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def expected_xml
|
|
31
|
+
<<EOS
|
|
32
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
33
|
+
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
|
|
34
|
+
<dimension ref="A1"/>
|
|
35
|
+
<sheetViews>
|
|
36
|
+
<sheetView tabSelected="1" workbookViewId="0"/>
|
|
37
|
+
</sheetViews>
|
|
38
|
+
<sheetFormatPr defaultRowHeight="15"/>
|
|
39
|
+
<sheetData/>
|
|
40
|
+
<conditionalFormatting sqref="A1">
|
|
41
|
+
<cfRule type="dataBar" priority="1">
|
|
42
|
+
<dataBar>
|
|
43
|
+
<cfvo type="min" val="0"/>
|
|
44
|
+
<cfvo type="max" val="0"/>
|
|
45
|
+
<color rgb="FF638EC6"/>
|
|
46
|
+
</dataBar>
|
|
47
|
+
</cfRule>
|
|
48
|
+
</conditionalFormatting>
|
|
49
|
+
<pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>
|
|
50
|
+
</worksheet>
|
|
51
|
+
EOS
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
|
|
4
|
+
class TestWorksheetDataBar02 < Minitest::Test
|
|
5
|
+
def setup
|
|
6
|
+
@workbook = WriteXLSX.new(StringIO.new)
|
|
7
|
+
@worksheet = @workbook.add_worksheet('')
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
###############################################################################
|
|
11
|
+
#
|
|
12
|
+
# Tests for WriteXLSX::Worksheet methods.
|
|
13
|
+
#
|
|
14
|
+
#
|
|
15
|
+
def test_data_bar_02
|
|
16
|
+
@worksheet.select
|
|
17
|
+
@worksheet.instance_variable_set(:@index, 0)
|
|
18
|
+
|
|
19
|
+
@worksheet.conditional_formatting(
|
|
20
|
+
'A1',
|
|
21
|
+
:type => 'data_bar',
|
|
22
|
+
:data_bar_2010 => 1
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
@worksheet.assemble_xml_file
|
|
26
|
+
result = got_to_array(@worksheet.instance_variable_get(:@writer).string)
|
|
27
|
+
|
|
28
|
+
expected = expected_to_array(expected_xml)
|
|
29
|
+
assert_equal(expected, result)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def expected_xml
|
|
33
|
+
<<EOS
|
|
34
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
35
|
+
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" mc:Ignorable="x14ac">
|
|
36
|
+
<dimension ref="A1"/>
|
|
37
|
+
<sheetViews>
|
|
38
|
+
<sheetView tabSelected="1" workbookViewId="0"/>
|
|
39
|
+
</sheetViews>
|
|
40
|
+
<sheetFormatPr defaultRowHeight="15" x14ac:dyDescent="0.25"/>
|
|
41
|
+
<sheetData/>
|
|
42
|
+
<conditionalFormatting sqref="A1">
|
|
43
|
+
<cfRule type="dataBar" priority="1">
|
|
44
|
+
<dataBar>
|
|
45
|
+
<cfvo type="min"/>
|
|
46
|
+
<cfvo type="max"/>
|
|
47
|
+
<color rgb="FF638EC6"/>
|
|
48
|
+
</dataBar>
|
|
49
|
+
<extLst>
|
|
50
|
+
<ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{B025F937-C7B1-47D3-B67F-A62EFF666E3E}">
|
|
51
|
+
<x14:id>{DA7ABA51-AAAA-BBBB-0001-000000000001}</x14:id>
|
|
52
|
+
</ext>
|
|
53
|
+
</extLst>
|
|
54
|
+
</cfRule>
|
|
55
|
+
</conditionalFormatting>
|
|
56
|
+
<pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>
|
|
57
|
+
<extLst>
|
|
58
|
+
<ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{78C0D931-6437-407d-A8EE-F0AAD7539E65}">
|
|
59
|
+
<x14:conditionalFormattings>
|
|
60
|
+
<x14:conditionalFormatting xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
|
|
61
|
+
<x14:cfRule type="dataBar" id="{DA7ABA51-AAAA-BBBB-0001-000000000001}">
|
|
62
|
+
<x14:dataBar minLength="0" maxLength="100" border="1" negativeBarBorderColorSameAsPositive="0">
|
|
63
|
+
<x14:cfvo type="autoMin"/>
|
|
64
|
+
<x14:cfvo type="autoMax"/>
|
|
65
|
+
<x14:borderColor rgb="FF638EC6"/>
|
|
66
|
+
<x14:negativeFillColor rgb="FFFF0000"/>
|
|
67
|
+
<x14:negativeBorderColor rgb="FFFF0000"/>
|
|
68
|
+
<x14:axisColor rgb="FF000000"/>
|
|
69
|
+
</x14:dataBar>
|
|
70
|
+
</x14:cfRule>
|
|
71
|
+
<xm:sqref>A1</xm:sqref>
|
|
72
|
+
</x14:conditionalFormatting>
|
|
73
|
+
</x14:conditionalFormattings>
|
|
74
|
+
</ext>
|
|
75
|
+
</extLst>
|
|
76
|
+
</worksheet>
|
|
77
|
+
EOS
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'helper'
|
|
3
|
+
|
|
4
|
+
class TestWorksheetDataBar03 < Minitest::Test
|
|
5
|
+
def setup
|
|
6
|
+
@workbook = WriteXLSX.new(StringIO.new)
|
|
7
|
+
@worksheet = @workbook.add_worksheet('')
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
###############################################################################
|
|
11
|
+
#
|
|
12
|
+
# Tests for WriteXLSX::Worksheet methods.
|
|
13
|
+
#
|
|
14
|
+
#
|
|
15
|
+
def test_data_bar_03
|
|
16
|
+
@worksheet.select
|
|
17
|
+
@worksheet.instance_variable_set(:@index, 0)
|
|
18
|
+
|
|
19
|
+
@worksheet.conditional_formatting(
|
|
20
|
+
'A1',
|
|
21
|
+
:type => 'data_bar',
|
|
22
|
+
:data_bar_2010 => 1
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
@worksheet.conditional_formatting(
|
|
26
|
+
'A2:B2',
|
|
27
|
+
:type => 'data_bar',
|
|
28
|
+
:bar_color => '#63C384',
|
|
29
|
+
:data_bar_2010 => 1
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
@worksheet.conditional_formatting(
|
|
33
|
+
'A3:C3',
|
|
34
|
+
:type => 'data_bar',
|
|
35
|
+
:bar_color => '#FF555A',
|
|
36
|
+
:data_bar_2010 => 1
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
@worksheet.assemble_xml_file
|
|
40
|
+
result = got_to_array(@worksheet.instance_variable_get(:@writer).string)
|
|
41
|
+
|
|
42
|
+
expected = expected_to_array(expected_xml)
|
|
43
|
+
assert_equal(expected, result)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def expected_xml
|
|
47
|
+
<<EOS
|
|
48
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
49
|
+
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" mc:Ignorable="x14ac">
|
|
50
|
+
<dimension ref="A1"/>
|
|
51
|
+
<sheetViews>
|
|
52
|
+
<sheetView tabSelected="1" workbookViewId="0"/>
|
|
53
|
+
</sheetViews>
|
|
54
|
+
<sheetFormatPr defaultRowHeight="15" x14ac:dyDescent="0.25"/>
|
|
55
|
+
<sheetData/>
|
|
56
|
+
<conditionalFormatting sqref="A1">
|
|
57
|
+
<cfRule type="dataBar" priority="1">
|
|
58
|
+
<dataBar>
|
|
59
|
+
<cfvo type="min"/>
|
|
60
|
+
<cfvo type="max"/>
|
|
61
|
+
<color rgb="FF638EC6"/>
|
|
62
|
+
</dataBar>
|
|
63
|
+
<extLst>
|
|
64
|
+
<ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{B025F937-C7B1-47D3-B67F-A62EFF666E3E}">
|
|
65
|
+
<x14:id>{DA7ABA51-AAAA-BBBB-0001-000000000001}</x14:id>
|
|
66
|
+
</ext>
|
|
67
|
+
</extLst>
|
|
68
|
+
</cfRule>
|
|
69
|
+
</conditionalFormatting>
|
|
70
|
+
<conditionalFormatting sqref="A2:B2">
|
|
71
|
+
<cfRule type="dataBar" priority="2">
|
|
72
|
+
<dataBar>
|
|
73
|
+
<cfvo type="min"/>
|
|
74
|
+
<cfvo type="max"/>
|
|
75
|
+
<color rgb="FF63C384"/>
|
|
76
|
+
</dataBar>
|
|
77
|
+
<extLst>
|
|
78
|
+
<ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{B025F937-C7B1-47D3-B67F-A62EFF666E3E}">
|
|
79
|
+
<x14:id>{DA7ABA51-AAAA-BBBB-0001-000000000002}</x14:id>
|
|
80
|
+
</ext>
|
|
81
|
+
</extLst>
|
|
82
|
+
</cfRule>
|
|
83
|
+
</conditionalFormatting>
|
|
84
|
+
<conditionalFormatting sqref="A3:C3">
|
|
85
|
+
<cfRule type="dataBar" priority="3">
|
|
86
|
+
<dataBar>
|
|
87
|
+
<cfvo type="min"/>
|
|
88
|
+
<cfvo type="max"/>
|
|
89
|
+
<color rgb="FFFF555A"/>
|
|
90
|
+
</dataBar>
|
|
91
|
+
<extLst>
|
|
92
|
+
<ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{B025F937-C7B1-47D3-B67F-A62EFF666E3E}">
|
|
93
|
+
<x14:id>{DA7ABA51-AAAA-BBBB-0001-000000000003}</x14:id>
|
|
94
|
+
</ext>
|
|
95
|
+
</extLst>
|
|
96
|
+
</cfRule>
|
|
97
|
+
</conditionalFormatting>
|
|
98
|
+
<pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>
|
|
99
|
+
<extLst>
|
|
100
|
+
<ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{78C0D931-6437-407d-A8EE-F0AAD7539E65}">
|
|
101
|
+
<x14:conditionalFormattings>
|
|
102
|
+
<x14:conditionalFormatting xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
|
|
103
|
+
<x14:cfRule type="dataBar" id="{DA7ABA51-AAAA-BBBB-0001-000000000001}">
|
|
104
|
+
<x14:dataBar minLength="0" maxLength="100" border="1" negativeBarBorderColorSameAsPositive="0">
|
|
105
|
+
<x14:cfvo type="autoMin"/>
|
|
106
|
+
<x14:cfvo type="autoMax"/>
|
|
107
|
+
<x14:borderColor rgb="FF638EC6"/>
|
|
108
|
+
<x14:negativeFillColor rgb="FFFF0000"/>
|
|
109
|
+
<x14:negativeBorderColor rgb="FFFF0000"/>
|
|
110
|
+
<x14:axisColor rgb="FF000000"/>
|
|
111
|
+
</x14:dataBar>
|
|
112
|
+
</x14:cfRule>
|
|
113
|
+
<xm:sqref>A1</xm:sqref>
|
|
114
|
+
</x14:conditionalFormatting>
|
|
115
|
+
<x14:conditionalFormatting xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
|
|
116
|
+
<x14:cfRule type="dataBar" id="{DA7ABA51-AAAA-BBBB-0001-000000000002}">
|
|
117
|
+
<x14:dataBar minLength="0" maxLength="100" border="1" negativeBarBorderColorSameAsPositive="0">
|
|
118
|
+
<x14:cfvo type="autoMin"/>
|
|
119
|
+
<x14:cfvo type="autoMax"/>
|
|
120
|
+
<x14:borderColor rgb="FF63C384"/>
|
|
121
|
+
<x14:negativeFillColor rgb="FFFF0000"/>
|
|
122
|
+
<x14:negativeBorderColor rgb="FFFF0000"/>
|
|
123
|
+
<x14:axisColor rgb="FF000000"/>
|
|
124
|
+
</x14:dataBar>
|
|
125
|
+
</x14:cfRule>
|
|
126
|
+
<xm:sqref>A2:B2</xm:sqref>
|
|
127
|
+
</x14:conditionalFormatting>
|
|
128
|
+
<x14:conditionalFormatting xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
|
|
129
|
+
<x14:cfRule type="dataBar" id="{DA7ABA51-AAAA-BBBB-0001-000000000003}">
|
|
130
|
+
<x14:dataBar minLength="0" maxLength="100" border="1" negativeBarBorderColorSameAsPositive="0">
|
|
131
|
+
<x14:cfvo type="autoMin"/>
|
|
132
|
+
<x14:cfvo type="autoMax"/>
|
|
133
|
+
<x14:borderColor rgb="FFFF555A"/>
|
|
134
|
+
<x14:negativeFillColor rgb="FFFF0000"/>
|
|
135
|
+
<x14:negativeBorderColor rgb="FFFF0000"/>
|
|
136
|
+
<x14:axisColor rgb="FF000000"/>
|
|
137
|
+
</x14:dataBar>
|
|
138
|
+
</x14:cfRule>
|
|
139
|
+
<xm:sqref>A3:C3</xm:sqref>
|
|
140
|
+
</x14:conditionalFormatting>
|
|
141
|
+
</x14:conditionalFormattings>
|
|
142
|
+
</ext>
|
|
143
|
+
</extLst>
|
|
144
|
+
</worksheet>
|
|
145
|
+
EOS
|
|
146
|
+
end
|
|
147
|
+
end
|