writeexcel 0.3.5 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitattributes +1 -0
- data/README.rdoc +12 -6
- data/VERSION +1 -1
- data/charts/chartex.rb +316 -315
- data/charts/demo1.rb +1 -0
- data/charts/demo2.rb +1 -0
- data/charts/demo3.rb +117 -116
- data/charts/demo4.rb +119 -118
- data/charts/demo5.rb +48 -47
- data/examples/a_simple.rb +1 -0
- data/examples/autofilter.rb +1 -0
- data/examples/bigfile.rb +30 -29
- data/examples/chart_area.rb +121 -120
- data/examples/chart_bar.rb +120 -119
- data/examples/chart_column.rb +120 -119
- data/examples/chart_line.rb +120 -119
- data/examples/chart_pie.rb +108 -107
- data/examples/chart_scatter.rb +121 -120
- data/examples/chart_stock.rb +148 -147
- data/examples/chess.rb +1 -0
- data/examples/colors.rb +1 -0
- data/examples/comments1.rb +1 -0
- data/examples/comments2.rb +3 -2
- data/examples/copyformat.rb +1 -0
- data/examples/data_validate.rb +1 -0
- data/examples/date_time.rb +1 -0
- data/examples/defined_name.rb +1 -0
- data/examples/demo.rb +1 -0
- data/examples/diag_border.rb +1 -0
- data/examples/formats.rb +1 -0
- data/examples/formula_result.rb +1 -0
- data/examples/header.rb +1 -0
- data/examples/hide_sheet.rb +1 -0
- data/examples/hyperlink.rb +1 -0
- data/examples/images.rb +1 -0
- data/examples/indent.rb +1 -0
- data/examples/merge1.rb +1 -0
- data/examples/merge2.rb +1 -0
- data/examples/merge3.rb +1 -0
- data/examples/merge4.rb +1 -0
- data/examples/merge5.rb +1 -0
- data/examples/merge6.rb +67 -66
- data/examples/outline.rb +1 -0
- data/examples/outline_collapsed.rb +1 -0
- data/examples/panes.rb +1 -0
- data/examples/properties.rb +1 -0
- data/examples/properties_jp.rb +1 -0
- data/examples/protection.rb +1 -0
- data/examples/regions.rb +1 -0
- data/examples/repeat.rb +1 -0
- data/examples/right_to_left.rb +1 -0
- data/examples/row_wrap.rb +1 -0
- data/examples/stats.rb +1 -0
- data/examples/stocks.rb +1 -0
- data/examples/tab_colors.rb +1 -0
- data/examples/write_arrays.rb +1 -0
- data/lib/writeexcel.rb +6 -1
- data/lib/writeexcel/biffwriter.rb +21 -20
- data/lib/writeexcel/chart.rb +25 -12
- data/lib/writeexcel/charts/area.rb +153 -152
- data/lib/writeexcel/charts/bar.rb +178 -177
- data/lib/writeexcel/charts/column.rb +157 -156
- data/lib/writeexcel/charts/external.rb +62 -61
- data/lib/writeexcel/charts/line.rb +153 -152
- data/lib/writeexcel/charts/pie.rb +170 -169
- data/lib/writeexcel/charts/scatter.rb +4 -3
- data/lib/writeexcel/charts/stock.rb +212 -211
- data/lib/writeexcel/compatibility.rb +320 -0
- data/lib/writeexcel/excelformulaparser.rb +587 -586
- data/lib/writeexcel/format.rb +12 -13
- data/lib/writeexcel/formula.rb +30 -28
- data/lib/writeexcel/helper.rb +23 -0
- data/lib/writeexcel/olewriter.rb +5 -16
- data/lib/writeexcel/properties.rb +43 -54
- data/lib/writeexcel/storage_lite.rb +981 -968
- data/lib/writeexcel/workbook.rb +94 -73
- data/lib/writeexcel/worksheet.rb +230 -210
- data/test/helper.rb +19 -0
- data/test/test_00_IEEE_double.rb +1 -0
- data/test/test_01_add_worksheet.rb +1 -0
- data/test/test_02_merge_formats.rb +3 -5
- data/test/test_04_dimensions.rb +3 -5
- data/test/test_05_rows.rb +6 -6
- data/test/test_06_extsst.rb +8 -8
- data/test/test_11_date_time.rb +3 -5
- data/test/test_12_date_only.rb +3 -5
- data/test/test_13_date_seconds.rb +4 -6
- data/test/test_21_escher.rb +3 -5
- data/test/test_22_mso_drawing_group.rb +20 -22
- data/test/test_23_note.rb +5 -7
- data/test/test_24_txo.rb +3 -5
- data/test/test_25_position_object.rb +84 -79
- data/test/test_26_autofilter.rb +3 -13
- data/test/test_27_autofilter.rb +3 -13
- data/test/test_28_autofilter.rb +3 -13
- data/test/test_29_process_jpg.rb +5 -0
- data/test/test_30_validation_dval.rb +3 -5
- data/test/test_31_validation_dv_strings.rb +3 -5
- data/test/test_32_validation_dv_formula.rb +3 -5
- data/test/test_40_property_types.rb +10 -9
- data/test/test_41_properties.rb +1 -0
- data/test/test_42_set_properties.rb +14 -15
- data/test/test_50_name_stored.rb +299 -302
- data/test/test_51_name_print_area.rb +357 -360
- data/test/test_52_name_print_titles.rb +454 -457
- data/test/test_53_autofilter.rb +203 -206
- data/test/test_60_chart_generic.rb +5 -0
- data/test/test_61_chart_subclasses.rb +95 -94
- data/test/test_62_chart_formats.rb +272 -267
- data/test/test_63_chart_area_formats.rb +649 -644
- data/test/test_biff.rb +12 -38
- data/test/test_compatibility.rb +627 -0
- data/test/test_example_match.rb +3 -18
- data/test/test_format.rb +46 -105
- data/test/test_formula.rb +1 -0
- data/test/test_ole.rb +3 -4
- data/test/test_storage_lite.rb +125 -146
- data/test/test_workbook.rb +2 -23
- data/test/test_worksheet.rb +4 -5
- data/utils/add_magic_comment.rb +80 -0
- data/writeexcel.gemspec +8 -2
- metadata +10 -4
@@ -1,457 +1,454 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
|
12
|
-
|
13
|
-
require '
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
@
|
19
|
-
@workbook.
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
@workbook.
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
@workbook.
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
@workbook.
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
@workbook.
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
@workbook.
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
@workbook.
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
@workbook.
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
@workbook.
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
@workbook.
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
@workbook.
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
@workbook.
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
@workbook.
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
@workbook.
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
worksheet3.
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
@workbook.
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
@workbook.
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
#
|
355
|
-
#
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
data[0, 2]
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
#
|
379
|
-
#
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
data[0, 2]
|
390
|
-
|
391
|
-
data[0,
|
392
|
-
|
393
|
-
data[0,
|
394
|
-
|
395
|
-
data[0,
|
396
|
-
|
397
|
-
data[0,
|
398
|
-
|
399
|
-
data[0, 2]
|
400
|
-
|
401
|
-
data[0,
|
402
|
-
|
403
|
-
data[0,
|
404
|
-
|
405
|
-
data[0, 1]
|
406
|
-
|
407
|
-
data[0, 1]
|
408
|
-
|
409
|
-
data[0, 1]
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
flag
|
417
|
-
flag['
|
418
|
-
flag['
|
419
|
-
flag['
|
420
|
-
flag['
|
421
|
-
flag['
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
name['
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
data[0,
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
data[0, name['str_len']]
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
end
|
456
|
-
end
|
457
|
-
end
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
##########################################################################
|
3
|
+
# test_52_name_print_titles.rb
|
4
|
+
#
|
5
|
+
# Tests for the Excel EXTERNSHEET and NAME records created by print_are()..
|
6
|
+
#
|
7
|
+
# reverse('ゥ'), September 2008, John McNamara, jmcnamara@cpan.org
|
8
|
+
#
|
9
|
+
# original written in Perl by John McNamara
|
10
|
+
# converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
|
11
|
+
#
|
12
|
+
#########################################################################
|
13
|
+
require 'helper'
|
14
|
+
require 'stringio'
|
15
|
+
|
16
|
+
class TC_Name_Print_Titles < Test::Unit::TestCase
|
17
|
+
def setup
|
18
|
+
@test_file = StringIO.new
|
19
|
+
@workbook = WriteExcel.new(@test_file)
|
20
|
+
@workbook.not_using_tmpfile
|
21
|
+
end
|
22
|
+
|
23
|
+
def teardown
|
24
|
+
@workbook.close
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_repeat_rows_for_top_row_only
|
28
|
+
worksheet1 = @workbook.add_worksheet
|
29
|
+
|
30
|
+
worksheet1.repeat_rows(0)
|
31
|
+
|
32
|
+
# Test the EXTERNSHEET record.
|
33
|
+
@workbook.calculate_extern_sizes
|
34
|
+
@workbook.store_externsheet
|
35
|
+
|
36
|
+
target = [%w(
|
37
|
+
17 00 08 00 01 00 00 00 00 00 00 00
|
38
|
+
).join('')].pack('H*')
|
39
|
+
|
40
|
+
caption = " \tExternsheet"
|
41
|
+
result = _unpack_externsheet(@workbook.data)
|
42
|
+
target = _unpack_externsheet(target)
|
43
|
+
assert_equal(target, result)
|
44
|
+
|
45
|
+
# Test the NAME record.
|
46
|
+
@workbook.clear_data_for_test
|
47
|
+
@workbook.store_names
|
48
|
+
|
49
|
+
target = [%w(
|
50
|
+
18 00 1B 00 20 00 00 01 0B 00 00 00 01 00 00 00
|
51
|
+
00 00 00 07 3B 00 00 00 00 00 00 00 00 FF 00
|
52
|
+
).join('')].pack('H*')
|
53
|
+
|
54
|
+
caption = " \t+ Name repeats ( Sheet1!1:1 )";
|
55
|
+
result = _unpack_name(@workbook.data)
|
56
|
+
target = _unpack_name(target)
|
57
|
+
assert_equal(target, result)
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_repeat_rows_for_top_10_rows
|
61
|
+
worksheet1 = @workbook.add_worksheet
|
62
|
+
|
63
|
+
worksheet1.repeat_rows(0, 9)
|
64
|
+
|
65
|
+
# Test the EXTERNSHEET record.
|
66
|
+
@workbook.calculate_extern_sizes
|
67
|
+
@workbook.store_externsheet
|
68
|
+
|
69
|
+
target = [%w(
|
70
|
+
17 00 08 00 01 00 00 00 00 00 00 00
|
71
|
+
).join('')].pack('H*')
|
72
|
+
|
73
|
+
caption = " \tExternsheet"
|
74
|
+
result = _unpack_externsheet(@workbook.data)
|
75
|
+
target = _unpack_externsheet(target)
|
76
|
+
assert_equal(target, result)
|
77
|
+
|
78
|
+
# Test the NAME record.
|
79
|
+
@workbook.clear_data_for_test
|
80
|
+
@workbook.store_names
|
81
|
+
|
82
|
+
target = [%w(
|
83
|
+
18 00 1B 00 20 00 00 01 0B 00 00 00 01 00 00 00
|
84
|
+
00 00 00 07 3B 00 00 00 00 09 00 00 00 FF 00
|
85
|
+
).join('')].pack('H*')
|
86
|
+
|
87
|
+
caption = " \t+ Name repeats ( Sheet1!1:10 )";
|
88
|
+
result = _unpack_name(@workbook.data)
|
89
|
+
target = _unpack_name(target)
|
90
|
+
assert_equal(target, result)
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_repeat_columns_for_a_single_column
|
94
|
+
worksheet1 = @workbook.add_worksheet
|
95
|
+
|
96
|
+
worksheet1.repeat_columns(0)
|
97
|
+
|
98
|
+
# Test the EXTERNSHEET record.
|
99
|
+
@workbook.calculate_extern_sizes
|
100
|
+
@workbook.store_externsheet
|
101
|
+
|
102
|
+
target = [%w(
|
103
|
+
17 00 08 00 01 00 00 00 00 00 00 00
|
104
|
+
).join('')].pack('H*')
|
105
|
+
|
106
|
+
caption = " \tExternsheet"
|
107
|
+
result = _unpack_externsheet(@workbook.data)
|
108
|
+
target = _unpack_externsheet(target)
|
109
|
+
assert_equal(target, result)
|
110
|
+
|
111
|
+
# Test the NAME record.
|
112
|
+
@workbook.clear_data_for_test
|
113
|
+
@workbook.store_names
|
114
|
+
|
115
|
+
target = [%w(
|
116
|
+
18 00 1B 00 20 00 00 01 0B 00 00 00 01 00 00 00
|
117
|
+
00 00 00 07 3B 00 00 00 00 FF FF 00 00 00 00
|
118
|
+
).join('')].pack('H*')
|
119
|
+
|
120
|
+
caption = " \t+ Name repeats ( Sheet1!A:A )";
|
121
|
+
result = _unpack_name(@workbook.data)
|
122
|
+
target = _unpack_name(target)
|
123
|
+
assert_equal(target, result)
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_repeat_columns_for_a_single_column_A1_notation
|
127
|
+
worksheet1 = @workbook.add_worksheet
|
128
|
+
|
129
|
+
worksheet1.repeat_columns('A:A')
|
130
|
+
|
131
|
+
# Test the EXTERNSHEET record.
|
132
|
+
@workbook.calculate_extern_sizes
|
133
|
+
@workbook.store_externsheet
|
134
|
+
|
135
|
+
target = [%w(
|
136
|
+
17 00 08 00 01 00 00 00 00 00 00 00
|
137
|
+
).join('')].pack('H*')
|
138
|
+
|
139
|
+
caption = " \tExternsheet"
|
140
|
+
result = _unpack_externsheet(@workbook.data)
|
141
|
+
target = _unpack_externsheet(target)
|
142
|
+
assert_equal(target, result)
|
143
|
+
|
144
|
+
# Test the NAME record.
|
145
|
+
@workbook.clear_data_for_test
|
146
|
+
@workbook.store_names
|
147
|
+
|
148
|
+
target = [%w(
|
149
|
+
18 00 1B 00 20 00 00 01 0B 00 00 00 01 00 00 00
|
150
|
+
00 00 00 07 3B 00 00 00 00 FF FF 00 00 00 00
|
151
|
+
).join('')].pack('H*')
|
152
|
+
|
153
|
+
caption = " \t+ Name repeats ( Sheet1!A:A )";
|
154
|
+
result = _unpack_name(@workbook.data)
|
155
|
+
target = _unpack_name(target)
|
156
|
+
assert_equal(target, result)
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_repeat_columns_for_a_10_columns
|
160
|
+
worksheet1 = @workbook.add_worksheet
|
161
|
+
|
162
|
+
worksheet1.repeat_columns(0, 9)
|
163
|
+
|
164
|
+
# Test the EXTERNSHEET record.
|
165
|
+
@workbook.calculate_extern_sizes
|
166
|
+
@workbook.store_externsheet
|
167
|
+
|
168
|
+
target = [%w(
|
169
|
+
17 00 08 00 01 00 00 00 00 00 00 00
|
170
|
+
).join('')].pack('H*')
|
171
|
+
|
172
|
+
caption = " \tExternsheet"
|
173
|
+
result = _unpack_externsheet(@workbook.data)
|
174
|
+
target = _unpack_externsheet(target)
|
175
|
+
assert_equal(target, result)
|
176
|
+
|
177
|
+
# Test the NAME record.
|
178
|
+
@workbook.clear_data_for_test
|
179
|
+
@workbook.store_names
|
180
|
+
|
181
|
+
target = [%w(
|
182
|
+
18 00 1B 00 20 00 00 01 0B 00 00 00 01 00 00 00
|
183
|
+
00 00 00 07 3B 00 00 00 00 FF FF 00 00 09 00
|
184
|
+
).join('')].pack('H*')
|
185
|
+
|
186
|
+
caption = " \t+ Name repeats ( Sheet1!A:J )";
|
187
|
+
result = _unpack_name(@workbook.data)
|
188
|
+
target = _unpack_name(target)
|
189
|
+
assert_equal(target, result)
|
190
|
+
end
|
191
|
+
|
192
|
+
def test_repeat_columns_for_a_10_columns_A1_notation
|
193
|
+
worksheet1 = @workbook.add_worksheet
|
194
|
+
|
195
|
+
worksheet1.repeat_columns('A:J')
|
196
|
+
|
197
|
+
# Test the EXTERNSHEET record.
|
198
|
+
@workbook.calculate_extern_sizes
|
199
|
+
@workbook.store_externsheet
|
200
|
+
|
201
|
+
target = [%w(
|
202
|
+
17 00 08 00 01 00 00 00 00 00 00 00
|
203
|
+
).join('')].pack('H*')
|
204
|
+
|
205
|
+
caption = " \tExternsheet"
|
206
|
+
result = _unpack_externsheet(@workbook.data)
|
207
|
+
target = _unpack_externsheet(target)
|
208
|
+
assert_equal(target, result)
|
209
|
+
|
210
|
+
# Test the NAME record.
|
211
|
+
@workbook.clear_data_for_test
|
212
|
+
@workbook.store_names
|
213
|
+
|
214
|
+
target = [%w(
|
215
|
+
18 00 1B 00 20 00 00 01 0B 00 00 00 01 00 00 00
|
216
|
+
00 00 00 07 3B 00 00 00 00 FF FF 00 00 09 00
|
217
|
+
).join('')].pack('H*')
|
218
|
+
|
219
|
+
caption = " \t+ Name repeats ( Sheet1!A:J )";
|
220
|
+
result = _unpack_name(@workbook.data)
|
221
|
+
target = _unpack_name(target)
|
222
|
+
assert_equal(target, result)
|
223
|
+
end
|
224
|
+
|
225
|
+
def test_repeat_rows_on_multiple_sheets
|
226
|
+
worksheet1 = @workbook.add_worksheet
|
227
|
+
worksheet2 = @workbook.add_worksheet
|
228
|
+
worksheet3 = @workbook.add_worksheet
|
229
|
+
|
230
|
+
worksheet1.repeat_rows(0, 1)
|
231
|
+
worksheet2.repeat_rows(3, 4)
|
232
|
+
worksheet3.repeat_rows(6, 7)
|
233
|
+
|
234
|
+
# Test the EXTERNSHEET record.
|
235
|
+
@workbook.calculate_extern_sizes
|
236
|
+
@workbook.store_externsheet
|
237
|
+
|
238
|
+
target = [%w(
|
239
|
+
17 00 14 00 03 00 00 00 00 00 00 00 00 00 01 00
|
240
|
+
01 00 00 00 02 00 02 00
|
241
|
+
).join('')].pack('H*')
|
242
|
+
|
243
|
+
caption = " \tExternsheet"
|
244
|
+
result = _unpack_externsheet(@workbook.data)
|
245
|
+
target = _unpack_externsheet(target)
|
246
|
+
assert_equal(target, result)
|
247
|
+
|
248
|
+
# Test the NAME record.
|
249
|
+
@workbook.clear_data_for_test
|
250
|
+
@workbook.store_names
|
251
|
+
|
252
|
+
target = [%w(
|
253
|
+
18 00 1B 00 20 00 00 01 0B 00 00 00 01 00 00 00
|
254
|
+
00 00 00 07 3B 00 00 00 00 01 00 00 00 FF 00
|
255
|
+
|
256
|
+
18 00 1B 00 20 00 00 01 0B 00 00 00 02 00 00 00
|
257
|
+
00 00 00 07 3B 01 00 03 00 04 00 00 00 FF 00
|
258
|
+
|
259
|
+
18 00 1B 00 20 00 00 01 0B 00 00 00 03 00 00 00
|
260
|
+
00 00 00 07 3B 02 00 06 00 07 00 00 00 FF 00
|
261
|
+
).join('')].pack('H*')
|
262
|
+
|
263
|
+
caption = " \t+ Name repeats ( Sheet1!1:2, Sheet2!4:5, Sheet3!7:8 )";
|
264
|
+
result = _unpack_name(@workbook.data)
|
265
|
+
target = _unpack_name(target)
|
266
|
+
assert_equal(target, result)
|
267
|
+
end
|
268
|
+
|
269
|
+
def test_repeat_rows_on_multiple_sheets_with_sheets_spaced_out
|
270
|
+
worksheet1 = @workbook.add_worksheet
|
271
|
+
worksheet2 = @workbook.add_worksheet
|
272
|
+
worksheet3 = @workbook.add_worksheet
|
273
|
+
worksheet4 = @workbook.add_worksheet
|
274
|
+
worksheet5 = @workbook.add_worksheet
|
275
|
+
|
276
|
+
worksheet1.repeat_rows(0, 1)
|
277
|
+
worksheet3.repeat_rows(3, 4)
|
278
|
+
worksheet5.repeat_rows(6, 7)
|
279
|
+
|
280
|
+
# Test the EXTERNSHEET record.
|
281
|
+
@workbook.calculate_extern_sizes
|
282
|
+
@workbook.store_externsheet
|
283
|
+
|
284
|
+
target = [%w(
|
285
|
+
17 00 14 00 03 00 00 00 00 00 00 00 00 00 02 00
|
286
|
+
02 00 00 00 04 00 04 00
|
287
|
+
).join('')].pack('H*')
|
288
|
+
|
289
|
+
caption = " \tExternsheet"
|
290
|
+
result = _unpack_externsheet(@workbook.data)
|
291
|
+
target = _unpack_externsheet(target)
|
292
|
+
assert_equal(target, result)
|
293
|
+
|
294
|
+
# Test the NAME record.
|
295
|
+
@workbook.clear_data_for_test
|
296
|
+
@workbook.store_names
|
297
|
+
|
298
|
+
target = [%w(
|
299
|
+
18 00 1B 00 20 00 00 01 0B 00 00 00 01 00 00 00
|
300
|
+
00 00 00 07 3B 00 00 00 00 01 00 00 00 FF 00
|
301
|
+
|
302
|
+
18 00 1B 00 20 00 00 01 0B 00 00 00 03 00 00 00
|
303
|
+
00 00 00 07 3B 01 00 03 00 04 00 00 00 FF 00
|
304
|
+
|
305
|
+
18 00 1B 00 20 00 00 01 0B 00 00 00 05 00 00 00
|
306
|
+
00 00 00 07 3B 02 00 06 00 07 00 00 00 FF 00
|
307
|
+
).join('')].pack('H*')
|
308
|
+
|
309
|
+
caption = " \t+ Name repeats ( Sheet1!1:2, Sheet3!4:5, Sheet5!7:8 )";
|
310
|
+
result = _unpack_name(@workbook.data)
|
311
|
+
target = _unpack_name(target)
|
312
|
+
assert_equal(target, result)
|
313
|
+
end
|
314
|
+
|
315
|
+
def test_repeat_rows_and_repeat_columns_together
|
316
|
+
worksheet1 = @workbook.add_worksheet
|
317
|
+
|
318
|
+
worksheet1.repeat_rows(1, 2)
|
319
|
+
worksheet1.repeat_columns(3, 4)
|
320
|
+
|
321
|
+
# Test the EXTERNSHEET record.
|
322
|
+
@workbook.calculate_extern_sizes
|
323
|
+
@workbook.store_externsheet
|
324
|
+
|
325
|
+
target = [%w(
|
326
|
+
17 00 08 00 01 00 00 00 00 00 00 00
|
327
|
+
).join('')].pack('H*')
|
328
|
+
|
329
|
+
caption = " \tExternsheet"
|
330
|
+
result = _unpack_externsheet(@workbook.data)
|
331
|
+
target = _unpack_externsheet(target)
|
332
|
+
assert_equal(target, result)
|
333
|
+
|
334
|
+
# Test the NAME record.
|
335
|
+
@workbook.clear_data_for_test
|
336
|
+
@workbook.store_names
|
337
|
+
|
338
|
+
target = [%w(
|
339
|
+
18 00 2A 00 20 00 00 01 1A 00 00 00 01 00 00 00
|
340
|
+
00 00 00 07 29 17 00 3B 00 00 00 00 FF FF 03 00
|
341
|
+
04 00 3B 00 00 01 00 02 00 00 00 FF 00 10
|
342
|
+
).join('')].pack('H*')
|
343
|
+
|
344
|
+
caption = " \t+ Name repeats ( Sheet1!2:3, Sheet1!D:E )";
|
345
|
+
result = _unpack_name(@workbook.data)
|
346
|
+
target = _unpack_name(target)
|
347
|
+
assert_equal(target, result)
|
348
|
+
end
|
349
|
+
|
350
|
+
###############################################################################
|
351
|
+
#
|
352
|
+
# _unpack_externsheet()
|
353
|
+
#
|
354
|
+
# Unpack the EXTERNSHEET recordfor easier comparison.
|
355
|
+
#
|
356
|
+
def _unpack_externsheet(data)
|
357
|
+
externsheet = Hash.new
|
358
|
+
|
359
|
+
externsheet['record'] = data[0, 2].unpack('v')[0]
|
360
|
+
data[0, 2] = ''
|
361
|
+
externsheet['length'] = data[0, 2].unpack('v')[0]
|
362
|
+
data[0, 2] = ''
|
363
|
+
externsheet['count'] = data[0, 2].unpack('v')[0]
|
364
|
+
data[0, 2] = ''
|
365
|
+
externsheet['array'] = [];
|
366
|
+
|
367
|
+
externsheet['count'].times do
|
368
|
+
externsheet['array'] << data[0, 6].unpack('vvv')
|
369
|
+
data[0, 6] = ''
|
370
|
+
end
|
371
|
+
externsheet
|
372
|
+
end
|
373
|
+
|
374
|
+
###############################################################################
|
375
|
+
#
|
376
|
+
# _unpack_name()
|
377
|
+
#
|
378
|
+
# Unpack 1 or more NAME structures into a AoH for easier comparison.
|
379
|
+
#
|
380
|
+
def _unpack_name(data)
|
381
|
+
names = Array.new
|
382
|
+
while data.length > 0
|
383
|
+
name = Hash.new
|
384
|
+
|
385
|
+
name['record'] = data[0, 2].unpack('v')[0]
|
386
|
+
data[0, 2] = ''
|
387
|
+
name['length'] = data[0, 2].unpack('v')[0]
|
388
|
+
data[0, 2] = ''
|
389
|
+
name['flags'] = data[0, 2].unpack('v')[0]
|
390
|
+
data[0, 2] = ''
|
391
|
+
name['shortcut'] = data[0, 1].unpack('C')[0]
|
392
|
+
data[0, 1] = ''
|
393
|
+
name['str_len'] = data[0, 1].unpack('C')[0]
|
394
|
+
data[0, 1] = ''
|
395
|
+
name['formula_len'] = data[0, 2].unpack('v')[0]
|
396
|
+
data[0, 2] = ''
|
397
|
+
name['itals'] = data[0, 2].unpack('v')[0]
|
398
|
+
data[0, 2] = ''
|
399
|
+
name['sheet_index'] = data[0, 2].unpack('v')[0]
|
400
|
+
data[0, 2] = ''
|
401
|
+
name['menu_len'] = data[0, 1].unpack('C')[0]
|
402
|
+
data[0, 1] = ''
|
403
|
+
name['desc_len'] = data[0, 1].unpack('C')[0]
|
404
|
+
data[0, 1] = ''
|
405
|
+
name['help_len'] = data[0, 1].unpack('C')[0]
|
406
|
+
data[0, 1] = ''
|
407
|
+
name['status_len'] = data[0, 1].unpack('C')[0]
|
408
|
+
data[0, 1] = ''
|
409
|
+
name['encoding'] = data[0, 1].unpack('C')[0]
|
410
|
+
data[0, 1] = ''
|
411
|
+
|
412
|
+
# Decode the individual flag fields.
|
413
|
+
flag = Hash.new
|
414
|
+
flag['hidden'] = name['flags'] & 0x0001
|
415
|
+
flag['function'] = name['flags'] & 0x0002
|
416
|
+
flag['vb'] = name['flags'] & 0x0004
|
417
|
+
flag['macro'] = name['flags'] & 0x0008
|
418
|
+
flag['complex'] = name['flags'] & 0x0010
|
419
|
+
flag['builtin'] = name['flags'] & 0x0020
|
420
|
+
flag['group'] = name['flags'] & 0x0FC0
|
421
|
+
flag['binary'] = name['flags'] & 0x1000
|
422
|
+
name['flags'] = flag
|
423
|
+
|
424
|
+
# Decode the string part of the NAME structure.
|
425
|
+
if name['encoding'] == 1
|
426
|
+
# UTF-16 name. Leave in hex.
|
427
|
+
name['string'] = data[0, 2 * name['str_len']].unpack('H*')[0].upcase
|
428
|
+
data[0, 2 * name['str_len']] = ''
|
429
|
+
elsif flag['builtin'] != 0
|
430
|
+
# 1 digit builtin name. Leave in hex.
|
431
|
+
name['string'] = data[0, name['str_len']].unpack('H*')[0].upcase
|
432
|
+
data[0, name['str_len']] = ''
|
433
|
+
else
|
434
|
+
# ASCII name.
|
435
|
+
name['string'] = data[0, name['str_len']].unpack('C*').pack('C*')
|
436
|
+
data[0, name['str_len']] = ''
|
437
|
+
end
|
438
|
+
|
439
|
+
# Keep the formula as a hex string.
|
440
|
+
name['formula'] = data[0, name['formula_len']].unpack('H*')[0].upcase
|
441
|
+
data[0, name['formula_len']] = ''
|
442
|
+
|
443
|
+
names << name
|
444
|
+
end
|
445
|
+
names
|
446
|
+
end
|
447
|
+
|
448
|
+
def assert_hash_equal?(result, target)
|
449
|
+
assert_equal(result.keys.sort, target.keys.sort)
|
450
|
+
result.each_key do |key|
|
451
|
+
assert_equal(result[key], target[key])
|
452
|
+
end
|
453
|
+
end
|
454
|
+
end
|