write_xlsx 0.54.0 → 0.55.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.
@@ -0,0 +1,114 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx'
4
+ require 'stringio'
5
+
6
+ class TestSparkline06 < Test::Unit::TestCase
7
+ def setup
8
+ @workbook = WriteXLSX.new(StringIO.new)
9
+ @worksheet = @workbook.add_worksheet
10
+ end
11
+
12
+ def test_sparkline06
13
+ @worksheet.instance_variable_set(:@excel_version, 2010)
14
+ @worksheet.select
15
+
16
+ data = [-2, 2, 3, -1, 0]
17
+
18
+ @worksheet.write('A1', data)
19
+ @worksheet.write('A2', data)
20
+
21
+ # Set up sparklines
22
+
23
+ @worksheet.add_sparkline(
24
+ {
25
+ :location => ['F1', 'F2'],
26
+ :range => ['A1:E1', 'A2:E2']
27
+ }
28
+ )
29
+
30
+ # End sparklines
31
+
32
+ @worksheet.assemble_xml_file
33
+ result = got_to_array(@worksheet.instance_variable_get(:@writer).string)
34
+
35
+ expected = expected_to_array(expected_xml)
36
+ assert_equal(expected, result)
37
+ end
38
+
39
+ def expected_xml
40
+ <<EOS
41
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
42
+ <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">
43
+ <dimension ref="A1:E2"/>
44
+ <sheetViews>
45
+ <sheetView tabSelected="1" workbookViewId="0"/>
46
+ </sheetViews>
47
+ <sheetFormatPr defaultRowHeight="15" x14ac:dyDescent="0.25"/>
48
+ <sheetData>
49
+ <row r="1" spans="1:5" x14ac:dyDescent="0.25">
50
+ <c r="A1">
51
+ <v>-2</v>
52
+ </c>
53
+ <c r="B1">
54
+ <v>2</v>
55
+ </c>
56
+ <c r="C1">
57
+ <v>3</v>
58
+ </c>
59
+ <c r="D1">
60
+ <v>-1</v>
61
+ </c>
62
+ <c r="E1">
63
+ <v>0</v>
64
+ </c>
65
+ </row>
66
+ <row r="2" spans="1:5" x14ac:dyDescent="0.25">
67
+ <c r="A2">
68
+ <v>-2</v>
69
+ </c>
70
+ <c r="B2">
71
+ <v>2</v>
72
+ </c>
73
+ <c r="C2">
74
+ <v>3</v>
75
+ </c>
76
+ <c r="D2">
77
+ <v>-1</v>
78
+ </c>
79
+ <c r="E2">
80
+ <v>0</v>
81
+ </c>
82
+ </row>
83
+ </sheetData>
84
+ <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>
85
+ <extLst>
86
+ <ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{05C60535-1F16-4fd2-B633-F4F36F0B64E0}">
87
+ <x14:sparklineGroups xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
88
+ <x14:sparklineGroup displayEmptyCellsAs="gap">
89
+ <x14:colorSeries theme="4" tint="-0.499984740745262"/>
90
+ <x14:colorNegative theme="5"/>
91
+ <x14:colorAxis rgb="FF000000"/>
92
+ <x14:colorMarkers theme="4" tint="-0.499984740745262"/>
93
+ <x14:colorFirst theme="4" tint="0.39997558519241921"/>
94
+ <x14:colorLast theme="4" tint="0.39997558519241921"/>
95
+ <x14:colorHigh theme="4"/>
96
+ <x14:colorLow theme="4"/>
97
+ <x14:sparklines>
98
+ <x14:sparkline>
99
+ <xm:f>Sheet1!A1:E1</xm:f>
100
+ <xm:sqref>F1</xm:sqref>
101
+ </x14:sparkline>
102
+ <x14:sparkline>
103
+ <xm:f>Sheet1!A2:E2</xm:f>
104
+ <xm:sqref>F2</xm:sqref>
105
+ </x14:sparkline>
106
+ </x14:sparklines>
107
+ </x14:sparklineGroup>
108
+ </x14:sparklineGroups>
109
+ </ext>
110
+ </extLst>
111
+ </worksheet>
112
+ EOS
113
+ end
114
+ end
@@ -0,0 +1,357 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'write_xlsx'
4
+ require 'stringio'
5
+
6
+ class TestSparkline07 < Test::Unit::TestCase
7
+ def setup
8
+ @workbook = WriteXLSX.new(StringIO.new)
9
+ @worksheet = @workbook.add_worksheet
10
+ end
11
+
12
+ def test_sparkline07
13
+ @worksheet.instance_variable_set(:@excel_version, 2010)
14
+ @worksheet.select
15
+
16
+ data = [-2, 2, 3, -1, 0]
17
+
18
+ @worksheet.write('A1', data)
19
+ @worksheet.write('A2', data)
20
+ @worksheet.write('A3', data)
21
+ @worksheet.write('A4', data)
22
+ @worksheet.write('A5', data)
23
+ @worksheet.write('A6', data)
24
+ @worksheet.write('A7', data)
25
+
26
+ # Set up sparklines
27
+
28
+ @worksheet.add_sparkline(
29
+ {
30
+ :location => 'F1',
31
+ :range => 'A1:E1',
32
+ :type => 'column',
33
+ :high_point => 1
34
+ }
35
+ )
36
+
37
+ @worksheet.add_sparkline(
38
+ {
39
+ :location => 'F2',
40
+ :range => 'A2:E2',
41
+ :type => 'column',
42
+ :low_point => 1
43
+ }
44
+ )
45
+
46
+ @worksheet.add_sparkline(
47
+ {
48
+ :location => 'F3',
49
+ :range => 'A3:E3',
50
+ :type => 'column',
51
+ :negative_points => 1
52
+ }
53
+ )
54
+
55
+ @worksheet.add_sparkline(
56
+ {
57
+ :location => 'F4',
58
+ :range => 'A4:E4',
59
+ :type => 'column',
60
+ :first_point => 1
61
+ }
62
+ )
63
+
64
+ @worksheet.add_sparkline(
65
+ {
66
+ :location => 'F5',
67
+ :range => 'A5:E5',
68
+ :type => 'column',
69
+ :last_point => 1
70
+ }
71
+ )
72
+
73
+ @worksheet.add_sparkline(
74
+ {
75
+ :location => 'F6',
76
+ :range => 'A6:E6',
77
+ :type => 'column',
78
+ :markers => 1
79
+ }
80
+ )
81
+
82
+ @worksheet.add_sparkline(
83
+ {
84
+ :location => 'F7',
85
+ :range => 'A7:E7',
86
+ :type => 'column',
87
+ :high_point => 1,
88
+ :low_point => 1,
89
+ :negative_points => 1,
90
+ :first_point => 1,
91
+ :last_point => 1,
92
+ :markers => 1
93
+ }
94
+ )
95
+
96
+ # End sparklines
97
+
98
+ @worksheet.assemble_xml_file
99
+ result = got_to_array(@worksheet.instance_variable_get(:@writer).string)
100
+
101
+ expected = expected_to_array(expected_xml)
102
+ assert_equal(expected, result)
103
+ end
104
+
105
+ def expected_xml
106
+ <<EOS
107
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
108
+ <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">
109
+ <dimension ref="A1:E7"/>
110
+ <sheetViews>
111
+ <sheetView tabSelected="1" workbookViewId="0"/>
112
+ </sheetViews>
113
+ <sheetFormatPr defaultRowHeight="15" x14ac:dyDescent="0.25"/>
114
+ <sheetData>
115
+ <row r="1" spans="1:5" x14ac:dyDescent="0.25">
116
+ <c r="A1">
117
+ <v>-2</v>
118
+ </c>
119
+ <c r="B1">
120
+ <v>2</v>
121
+ </c>
122
+ <c r="C1">
123
+ <v>3</v>
124
+ </c>
125
+ <c r="D1">
126
+ <v>-1</v>
127
+ </c>
128
+ <c r="E1">
129
+ <v>0</v>
130
+ </c>
131
+ </row>
132
+ <row r="2" spans="1:5" x14ac:dyDescent="0.25">
133
+ <c r="A2">
134
+ <v>-2</v>
135
+ </c>
136
+ <c r="B2">
137
+ <v>2</v>
138
+ </c>
139
+ <c r="C2">
140
+ <v>3</v>
141
+ </c>
142
+ <c r="D2">
143
+ <v>-1</v>
144
+ </c>
145
+ <c r="E2">
146
+ <v>0</v>
147
+ </c>
148
+ </row>
149
+ <row r="3" spans="1:5" x14ac:dyDescent="0.25">
150
+ <c r="A3">
151
+ <v>-2</v>
152
+ </c>
153
+ <c r="B3">
154
+ <v>2</v>
155
+ </c>
156
+ <c r="C3">
157
+ <v>3</v>
158
+ </c>
159
+ <c r="D3">
160
+ <v>-1</v>
161
+ </c>
162
+ <c r="E3">
163
+ <v>0</v>
164
+ </c>
165
+ </row>
166
+ <row r="4" spans="1:5" x14ac:dyDescent="0.25">
167
+ <c r="A4">
168
+ <v>-2</v>
169
+ </c>
170
+ <c r="B4">
171
+ <v>2</v>
172
+ </c>
173
+ <c r="C4">
174
+ <v>3</v>
175
+ </c>
176
+ <c r="D4">
177
+ <v>-1</v>
178
+ </c>
179
+ <c r="E4">
180
+ <v>0</v>
181
+ </c>
182
+ </row>
183
+ <row r="5" spans="1:5" x14ac:dyDescent="0.25">
184
+ <c r="A5">
185
+ <v>-2</v>
186
+ </c>
187
+ <c r="B5">
188
+ <v>2</v>
189
+ </c>
190
+ <c r="C5">
191
+ <v>3</v>
192
+ </c>
193
+ <c r="D5">
194
+ <v>-1</v>
195
+ </c>
196
+ <c r="E5">
197
+ <v>0</v>
198
+ </c>
199
+ </row>
200
+ <row r="6" spans="1:5" x14ac:dyDescent="0.25">
201
+ <c r="A6">
202
+ <v>-2</v>
203
+ </c>
204
+ <c r="B6">
205
+ <v>2</v>
206
+ </c>
207
+ <c r="C6">
208
+ <v>3</v>
209
+ </c>
210
+ <c r="D6">
211
+ <v>-1</v>
212
+ </c>
213
+ <c r="E6">
214
+ <v>0</v>
215
+ </c>
216
+ </row>
217
+ <row r="7" spans="1:5" x14ac:dyDescent="0.25">
218
+ <c r="A7">
219
+ <v>-2</v>
220
+ </c>
221
+ <c r="B7">
222
+ <v>2</v>
223
+ </c>
224
+ <c r="C7">
225
+ <v>3</v>
226
+ </c>
227
+ <c r="D7">
228
+ <v>-1</v>
229
+ </c>
230
+ <c r="E7">
231
+ <v>0</v>
232
+ </c>
233
+ </row>
234
+ </sheetData>
235
+ <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>
236
+ <extLst>
237
+ <ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{05C60535-1F16-4fd2-B633-F4F36F0B64E0}">
238
+ <x14:sparklineGroups xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
239
+ <x14:sparklineGroup type="column" displayEmptyCellsAs="gap" markers="1" high="1" low="1" first="1" last="1" negative="1">
240
+ <x14:colorSeries theme="4" tint="-0.499984740745262"/>
241
+ <x14:colorNegative theme="5"/>
242
+ <x14:colorAxis rgb="FF000000"/>
243
+ <x14:colorMarkers theme="4" tint="-0.499984740745262"/>
244
+ <x14:colorFirst theme="4" tint="0.39997558519241921"/>
245
+ <x14:colorLast theme="4" tint="0.39997558519241921"/>
246
+ <x14:colorHigh theme="4"/>
247
+ <x14:colorLow theme="4"/>
248
+ <x14:sparklines>
249
+ <x14:sparkline>
250
+ <xm:f>Sheet1!A7:E7</xm:f>
251
+ <xm:sqref>F7</xm:sqref>
252
+ </x14:sparkline>
253
+ </x14:sparklines>
254
+ </x14:sparklineGroup>
255
+ <x14:sparklineGroup type="column" displayEmptyCellsAs="gap" markers="1">
256
+ <x14:colorSeries theme="4" tint="-0.499984740745262"/>
257
+ <x14:colorNegative theme="5"/>
258
+ <x14:colorAxis rgb="FF000000"/>
259
+ <x14:colorMarkers theme="4" tint="-0.499984740745262"/>
260
+ <x14:colorFirst theme="4" tint="0.39997558519241921"/>
261
+ <x14:colorLast theme="4" tint="0.39997558519241921"/>
262
+ <x14:colorHigh theme="4"/>
263
+ <x14:colorLow theme="4"/>
264
+ <x14:sparklines>
265
+ <x14:sparkline>
266
+ <xm:f>Sheet1!A6:E6</xm:f>
267
+ <xm:sqref>F6</xm:sqref>
268
+ </x14:sparkline>
269
+ </x14:sparklines>
270
+ </x14:sparklineGroup>
271
+ <x14:sparklineGroup type="column" displayEmptyCellsAs="gap" last="1">
272
+ <x14:colorSeries theme="4" tint="-0.499984740745262"/>
273
+ <x14:colorNegative theme="5"/>
274
+ <x14:colorAxis rgb="FF000000"/>
275
+ <x14:colorMarkers theme="4" tint="-0.499984740745262"/>
276
+ <x14:colorFirst theme="4" tint="0.39997558519241921"/>
277
+ <x14:colorLast theme="4" tint="0.39997558519241921"/>
278
+ <x14:colorHigh theme="4"/>
279
+ <x14:colorLow theme="4"/>
280
+ <x14:sparklines>
281
+ <x14:sparkline>
282
+ <xm:f>Sheet1!A5:E5</xm:f>
283
+ <xm:sqref>F5</xm:sqref>
284
+ </x14:sparkline>
285
+ </x14:sparklines>
286
+ </x14:sparklineGroup>
287
+ <x14:sparklineGroup type="column" displayEmptyCellsAs="gap" first="1">
288
+ <x14:colorSeries theme="4" tint="-0.499984740745262"/>
289
+ <x14:colorNegative theme="5"/>
290
+ <x14:colorAxis rgb="FF000000"/>
291
+ <x14:colorMarkers theme="4" tint="-0.499984740745262"/>
292
+ <x14:colorFirst theme="4" tint="0.39997558519241921"/>
293
+ <x14:colorLast theme="4" tint="0.39997558519241921"/>
294
+ <x14:colorHigh theme="4"/>
295
+ <x14:colorLow theme="4"/>
296
+ <x14:sparklines>
297
+ <x14:sparkline>
298
+ <xm:f>Sheet1!A4:E4</xm:f>
299
+ <xm:sqref>F4</xm:sqref>
300
+ </x14:sparkline>
301
+ </x14:sparklines>
302
+ </x14:sparklineGroup>
303
+ <x14:sparklineGroup type="column" displayEmptyCellsAs="gap" negative="1">
304
+ <x14:colorSeries theme="4" tint="-0.499984740745262"/>
305
+ <x14:colorNegative theme="5"/>
306
+ <x14:colorAxis rgb="FF000000"/>
307
+ <x14:colorMarkers theme="4" tint="-0.499984740745262"/>
308
+ <x14:colorFirst theme="4" tint="0.39997558519241921"/>
309
+ <x14:colorLast theme="4" tint="0.39997558519241921"/>
310
+ <x14:colorHigh theme="4"/>
311
+ <x14:colorLow theme="4"/>
312
+ <x14:sparklines>
313
+ <x14:sparkline>
314
+ <xm:f>Sheet1!A3:E3</xm:f>
315
+ <xm:sqref>F3</xm:sqref>
316
+ </x14:sparkline>
317
+ </x14:sparklines>
318
+ </x14:sparklineGroup>
319
+ <x14:sparklineGroup type="column" displayEmptyCellsAs="gap" low="1">
320
+ <x14:colorSeries theme="4" tint="-0.499984740745262"/>
321
+ <x14:colorNegative theme="5"/>
322
+ <x14:colorAxis rgb="FF000000"/>
323
+ <x14:colorMarkers theme="4" tint="-0.499984740745262"/>
324
+ <x14:colorFirst theme="4" tint="0.39997558519241921"/>
325
+ <x14:colorLast theme="4" tint="0.39997558519241921"/>
326
+ <x14:colorHigh theme="4"/>
327
+ <x14:colorLow theme="4"/>
328
+ <x14:sparklines>
329
+ <x14:sparkline>
330
+ <xm:f>Sheet1!A2:E2</xm:f>
331
+ <xm:sqref>F2</xm:sqref>
332
+ </x14:sparkline>
333
+ </x14:sparklines>
334
+ </x14:sparklineGroup>
335
+ <x14:sparklineGroup type="column" displayEmptyCellsAs="gap" high="1">
336
+ <x14:colorSeries theme="4" tint="-0.499984740745262"/>
337
+ <x14:colorNegative theme="5"/>
338
+ <x14:colorAxis rgb="FF000000"/>
339
+ <x14:colorMarkers theme="4" tint="-0.499984740745262"/>
340
+ <x14:colorFirst theme="4" tint="0.39997558519241921"/>
341
+ <x14:colorLast theme="4" tint="0.39997558519241921"/>
342
+ <x14:colorHigh theme="4"/>
343
+ <x14:colorLow theme="4"/>
344
+ <x14:sparklines>
345
+ <x14:sparkline>
346
+ <xm:f>Sheet1!A1:E1</xm:f>
347
+ <xm:sqref>F1</xm:sqref>
348
+ </x14:sparkline>
349
+ </x14:sparklines>
350
+ </x14:sparklineGroup>
351
+ </x14:sparklineGroups>
352
+ </ext>
353
+ </extLst>
354
+ </worksheet>
355
+ EOS
356
+ end
357
+ end