WriteExcel 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +47 -0
- data/VERSION +1 -0
- data/examples/a_simple.rb +42 -0
- data/examples/autofilters.rb +266 -0
- data/examples/bigfile.rb +30 -0
- data/examples/copyformat.rb +51 -0
- data/examples/data_validate.rb +278 -0
- data/examples/date_time.rb +86 -0
- data/examples/demo.rb +118 -0
- data/examples/diag_border.rb +35 -0
- data/examples/formats.rb +489 -0
- data/examples/header.rb +136 -0
- data/examples/hidden.rb +28 -0
- data/examples/hyperlink.rb +42 -0
- data/examples/images.rb +52 -0
- data/examples/merge1.rb +39 -0
- data/examples/merge2.rb +44 -0
- data/examples/merge3.rb +65 -0
- data/examples/merge4.rb +82 -0
- data/examples/merge5.rb +79 -0
- data/examples/protection.rb +46 -0
- data/examples/regions.rb +52 -0
- data/examples/repeat.rb +42 -0
- data/examples/stats.rb +75 -0
- data/examples/stocks.rb +80 -0
- data/examples/tab_colors.rb +30 -0
- data/lib/WriteExcel.rb +30 -0
- data/lib/WriteExcel/biffwriter.rb +259 -0
- data/lib/WriteExcel/chart.rb +217 -0
- data/lib/WriteExcel/excelformula.y +138 -0
- data/lib/WriteExcel/excelformulaparser.rb +573 -0
- data/lib/WriteExcel/format.rb +1108 -0
- data/lib/WriteExcel/formula.rb +986 -0
- data/lib/WriteExcel/olewriter.rb +322 -0
- data/lib/WriteExcel/properties.rb +250 -0
- data/lib/WriteExcel/storage_lite.rb +590 -0
- data/lib/WriteExcel/workbook.rb +2602 -0
- data/lib/WriteExcel/worksheet.rb +6378 -0
- data/spec/WriteExcel_spec.rb +7 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +9 -0
- data/test/tc_all.rb +31 -0
- data/test/tc_biff.rb +104 -0
- data/test/tc_chart.rb +22 -0
- data/test/tc_example_match.rb +1280 -0
- data/test/tc_format.rb +1264 -0
- data/test/tc_formula.rb +63 -0
- data/test/tc_ole.rb +110 -0
- data/test/tc_storage_lite.rb +102 -0
- data/test/tc_workbook.rb +115 -0
- data/test/tc_worksheet.rb +115 -0
- data/test/test_00_IEEE_double.rb +14 -0
- data/test/test_01_add_worksheet.rb +12 -0
- data/test/test_02_merge_formats.rb +58 -0
- data/test/test_04_dimensions.rb +397 -0
- data/test/test_05_rows.rb +182 -0
- data/test/test_06_extsst.rb +80 -0
- data/test/test_11_date_time.rb +484 -0
- data/test/test_12_date_only.rb +506 -0
- data/test/test_13_date_seconds.rb +486 -0
- data/test/test_21_escher.rb +629 -0
- data/test/test_22_mso_drawing_group.rb +739 -0
- data/test/test_23_note.rb +78 -0
- data/test/test_24_txo.rb +80 -0
- data/test/test_26_autofilter.rb +327 -0
- data/test/test_27_autofilter.rb +144 -0
- data/test/test_28_autofilter.rb +174 -0
- data/test/test_29_process_jpg.rb +131 -0
- data/test/test_30_validation_dval.rb +82 -0
- data/test/test_31_validation_dv_strings.rb +131 -0
- data/test/test_32_validation_dv_formula.rb +211 -0
- data/test/test_40_property_types.rb +191 -0
- data/test/test_41_properties.rb +238 -0
- data/test/test_42_set_properties.rb +430 -0
- data/test/ts_all.rb +34 -0
- metadata +154 -0
@@ -0,0 +1,629 @@
|
|
1
|
+
###############################################################################
|
2
|
+
#
|
3
|
+
# A test for Spreadsheet::WriteExcel.
|
4
|
+
#
|
5
|
+
# Tests for the internal methods used to write the records in an Escher drawing
|
6
|
+
# object such as images, comments and filters.
|
7
|
+
#
|
8
|
+
# reverse('©'), September 2005, John McNamara, jmcnamara@cpan.org
|
9
|
+
#
|
10
|
+
# original written in Perl by John McNamara
|
11
|
+
# converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
|
12
|
+
#
|
13
|
+
############################################################################
|
14
|
+
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
|
15
|
+
|
16
|
+
require "test/unit"
|
17
|
+
require 'WriteExcel'
|
18
|
+
|
19
|
+
class TC_escher < Test::Unit::TestCase
|
20
|
+
|
21
|
+
def setup
|
22
|
+
t = Time.now.strftime("%Y%m%d")
|
23
|
+
path = "temp#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
|
24
|
+
@test_file = File.join(Dir.tmpdir, path)
|
25
|
+
@workbook = Spreadsheet::WriteExcel.new(@test_file)
|
26
|
+
@worksheet = @workbook.add_worksheet
|
27
|
+
end
|
28
|
+
|
29
|
+
def teardown
|
30
|
+
@workbook.close
|
31
|
+
File.unlink(@test_file) if FileTest.exist?(@test_file)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_for_the_generic_method
|
35
|
+
data_for_test.each do |data|
|
36
|
+
caption = data.shift
|
37
|
+
target = data.pop
|
38
|
+
|
39
|
+
data[3].gsub!(/ /,'')
|
40
|
+
data[3] = [data[3]].pack('H*')
|
41
|
+
|
42
|
+
caption = sprintf(" \t_add_mso_generic(): (0x%04X) %s", data[0], caption)
|
43
|
+
|
44
|
+
result = unpack_record(@worksheet.add_mso_generic(*data))
|
45
|
+
|
46
|
+
assert_equal(target, result, caption)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_for_store_mso_dgg_container
|
51
|
+
caption = sprintf(" \t_store_mso_dgg_container()")
|
52
|
+
target = %w( 0F 00 00 F0 52 00 00 00 ).join(' ')
|
53
|
+
|
54
|
+
@workbook.mso_size = 94
|
55
|
+
result = unpack_record(@workbook.store_mso_dgg_container)
|
56
|
+
|
57
|
+
assert_equal(target, result, caption)
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_for_store_mso_dgg
|
61
|
+
caption = sprintf(" \t_store_mso_dgg()")
|
62
|
+
data = [ 1026, 2, 2, 1, [[1,2]] ]
|
63
|
+
target = %w( 00 00 06 F0
|
64
|
+
18 00 00 00 02 04 00 00 02 00 00 00 02 00 00 00
|
65
|
+
01 00 00 00 01 00 00 00 02 00 00 00
|
66
|
+
).join(' ')
|
67
|
+
|
68
|
+
result = unpack_record(@workbook.store_mso_dgg(*data))
|
69
|
+
|
70
|
+
assert_equal(target, result, caption)
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_for_store_mso_opt
|
74
|
+
caption = sprintf(" \t_store_mso_opt()")
|
75
|
+
target = %w( 33 00 0B F0
|
76
|
+
12 00 00 00 BF 00 08 00 08 00 81 01 09 00 00 08
|
77
|
+
C0 01 40 00 00 08
|
78
|
+
).join(' ')
|
79
|
+
|
80
|
+
result = unpack_record(@workbook.store_mso_opt)
|
81
|
+
|
82
|
+
assert_equal(target, result, caption)
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_for_store_mso_split_menu_colors
|
86
|
+
caption = sprintf(" \t_store_mso_split_menu_colors()")
|
87
|
+
target = %w( 40 00 1E F1 10 00 00 00 0D 00
|
88
|
+
00 08 0C 00 00 08 17 00 00 08 F7 00 00 10
|
89
|
+
).join(' ')
|
90
|
+
|
91
|
+
result = unpack_record(@workbook.store_mso_split_menu_colors)
|
92
|
+
|
93
|
+
assert_equal(target, result, caption)
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_for_store_mso_dg_container
|
97
|
+
caption = sprintf(" \t_store_mso_dg_container()")
|
98
|
+
data = [0xC8]
|
99
|
+
target = %w( 0F 00 02 F0 C8 00 00 00 ).join(' ')
|
100
|
+
|
101
|
+
result = unpack_record(@worksheet.store_mso_dg_container(*data))
|
102
|
+
|
103
|
+
assert_equal(target, result, caption)
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_for_store_mso_dg
|
107
|
+
caption = sprintf(" \t_store_mso_dg()")
|
108
|
+
data = [1, 2, 1025]
|
109
|
+
target = %w( 10 00 08 F0
|
110
|
+
08 00 00 00 02 00 00 00 01 04 00 00
|
111
|
+
).join(' ')
|
112
|
+
|
113
|
+
result = unpack_record(@worksheet.store_mso_dg(*data))
|
114
|
+
|
115
|
+
assert_equal(target, result, caption)
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_for_store_mso_spgr_container
|
119
|
+
caption = sprintf(" \t_store_mso_spgr_container()")
|
120
|
+
data = [0xB0]
|
121
|
+
target = %w(
|
122
|
+
0F 00 03 F0 B0 00 00 00
|
123
|
+
).join(' ')
|
124
|
+
|
125
|
+
result = unpack_record(@worksheet.store_mso_spgr_container(*data))
|
126
|
+
|
127
|
+
assert_equal(target, result, caption)
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_for_store_mso_sp_container
|
131
|
+
caption = sprintf(" \t_store_mso_sp_container()")
|
132
|
+
data = [0x28]
|
133
|
+
target = %w(
|
134
|
+
0F 00 04 F0 28 00 00 00
|
135
|
+
).join(' ')
|
136
|
+
|
137
|
+
result = unpack_record(@worksheet.store_mso_sp_container(*data))
|
138
|
+
|
139
|
+
assert_equal(target, result, caption)
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_for_store_mso_sp
|
143
|
+
caption = sprintf(" \t_store_mso_sp()")
|
144
|
+
data = [0, 1024, 0x0005]
|
145
|
+
target = %w(
|
146
|
+
02 00 0A F0 08 00 00 00 00 04 00 00 05 00 00 00
|
147
|
+
).join(' ')
|
148
|
+
|
149
|
+
result = unpack_record(@worksheet.store_mso_sp(*data))
|
150
|
+
|
151
|
+
assert_equal(target, result, caption)
|
152
|
+
|
153
|
+
data = [202, 1025, 0x0A00]
|
154
|
+
target = %w(
|
155
|
+
A2 0C 0A F0 08 00 00 00 01 04 00 00 00 0A 00 00
|
156
|
+
).join(' ')
|
157
|
+
|
158
|
+
result = unpack_record(@worksheet.store_mso_sp(*data))
|
159
|
+
|
160
|
+
assert_equal(target, result, caption)
|
161
|
+
end
|
162
|
+
|
163
|
+
def test_for_store_mso_opt_comment
|
164
|
+
caption = sprintf(" \t_store_mso_opt_comment()")
|
165
|
+
data = [0x80]
|
166
|
+
target = %w(
|
167
|
+
93 00 0B F0 36 00 00 00
|
168
|
+
80 00 00 00 00 00 BF 00 08 00 08 00
|
169
|
+
58 01 00 00 00 00 81 01 50 00 00 08 83 01 50 00
|
170
|
+
00 08 BF 01 10 00 11 00 01 02 00 00 00 00 3F 02
|
171
|
+
03 00 03 00 BF 03 02 00 0A 00
|
172
|
+
).join(' ')
|
173
|
+
|
174
|
+
result = unpack_record(@worksheet.store_mso_opt_comment(*data))
|
175
|
+
|
176
|
+
assert_equal(target, result, caption)
|
177
|
+
end
|
178
|
+
|
179
|
+
def test_for_store_mso_client_anchor
|
180
|
+
|
181
|
+
# A1
|
182
|
+
range = 'A1'
|
183
|
+
caption = sprintf(" \t_store_mso_client_anchor(%s)", range)
|
184
|
+
data = @worksheet.substitute_cellref(range)
|
185
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
186
|
+
data = data[-1]
|
187
|
+
target = %w(
|
188
|
+
00 00 10 F0 12 00 00 00 03 00 01 00 F0 00 00 00
|
189
|
+
1E 00 03 00 F0 00 04 00 78 00
|
190
|
+
).join(' ')
|
191
|
+
|
192
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
193
|
+
|
194
|
+
assert_equal(target, result, caption)
|
195
|
+
|
196
|
+
# A2
|
197
|
+
range = 'A2'
|
198
|
+
data = @worksheet.substitute_cellref(range)
|
199
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
200
|
+
data = data[-1]
|
201
|
+
target = %w(
|
202
|
+
00 00 10 F0 12 00 00 00 03 00 01 00 F0 00 00 00
|
203
|
+
69 00 03 00 F0 00 04 00 C4 00
|
204
|
+
).join(' ')
|
205
|
+
|
206
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
207
|
+
|
208
|
+
assert_equal(target, result, caption)
|
209
|
+
|
210
|
+
|
211
|
+
# A3
|
212
|
+
range = 'A3'
|
213
|
+
data = @worksheet.substitute_cellref(range)
|
214
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
215
|
+
data = data[-1]
|
216
|
+
target = %w(
|
217
|
+
00 00 10 F0 12 00 00 00 03 00 01 00 F0 00 01 00
|
218
|
+
69 00 03 00 F0 00 05 00 C4 00
|
219
|
+
).join(' ')
|
220
|
+
|
221
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
222
|
+
|
223
|
+
assert_equal(target, result, caption)
|
224
|
+
|
225
|
+
|
226
|
+
# A65534
|
227
|
+
range = 'A65534'
|
228
|
+
data = @worksheet.substitute_cellref(range)
|
229
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
230
|
+
data = data[-1]
|
231
|
+
target = %w(
|
232
|
+
00 00 10 F0 12 00 00 00 03 00 01 00 F0 00 F9 FF
|
233
|
+
3C 00 03 00 F0 00 FD FF 97 00
|
234
|
+
).join(' ')
|
235
|
+
|
236
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
237
|
+
|
238
|
+
assert_equal(target, result, caption)
|
239
|
+
|
240
|
+
|
241
|
+
# A65536
|
242
|
+
range = 'A65536'
|
243
|
+
data = @worksheet.substitute_cellref(range)
|
244
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
245
|
+
data = data[-1]
|
246
|
+
target = %w(
|
247
|
+
00 00 10 F0 12 00 00 00 03 00 01 00 F0 00 FB FF
|
248
|
+
1E 00 03 00 F0 00 FF FF 78 00
|
249
|
+
).join(' ')
|
250
|
+
|
251
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
252
|
+
|
253
|
+
assert_equal(target, result, caption)
|
254
|
+
|
255
|
+
|
256
|
+
# IT3
|
257
|
+
range = 'IT3'
|
258
|
+
data = @worksheet.substitute_cellref(range)
|
259
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
260
|
+
data = data[-1]
|
261
|
+
target = %w(
|
262
|
+
00 00 10 F0 12 00 00 00 03 00 FA 00 10 03 01 00
|
263
|
+
69 00 FC 00 10 03 05 00 C4 00
|
264
|
+
).join(' ')
|
265
|
+
|
266
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
267
|
+
|
268
|
+
assert_equal(target, result, caption)
|
269
|
+
|
270
|
+
|
271
|
+
# IU3
|
272
|
+
range = 'IU3'
|
273
|
+
data = @worksheet.substitute_cellref(range)
|
274
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
275
|
+
data = data[-1]
|
276
|
+
target = %w(
|
277
|
+
00 00 10 F0 12 00 00 00 03 00 FB 00 10 03 01 00
|
278
|
+
69 00 FD 00 10 03 05 00 C4 00
|
279
|
+
).join(' ')
|
280
|
+
|
281
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
282
|
+
|
283
|
+
assert_equal(target, result, caption)
|
284
|
+
|
285
|
+
|
286
|
+
#
|
287
|
+
range = 'IU3'
|
288
|
+
data = @worksheet.substitute_cellref(range)
|
289
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
290
|
+
data = data[-1]
|
291
|
+
target = %w(
|
292
|
+
00 00 10 F0 12 00 00 00 03 00 FB 00 10 03 01 00
|
293
|
+
69 00 FD 00 10 03 05 00 C4 00
|
294
|
+
).join(' ')
|
295
|
+
|
296
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
297
|
+
|
298
|
+
assert_equal(target, result, caption)
|
299
|
+
|
300
|
+
|
301
|
+
# IV3
|
302
|
+
range = 'IV3'
|
303
|
+
data = @worksheet.substitute_cellref(range)
|
304
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
305
|
+
data = data[-1]
|
306
|
+
target = %w(
|
307
|
+
00 00 10 F0 12 00 00 00 03 00 FC 00 10 03 01 00
|
308
|
+
69 00 FE 00 10 03 05 00 C4 00
|
309
|
+
).join(' ')
|
310
|
+
|
311
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
312
|
+
|
313
|
+
assert_equal(target, result, caption)
|
314
|
+
|
315
|
+
end
|
316
|
+
|
317
|
+
def test_for_store_mso_client_anchor_where_comment_offsets_have_changed
|
318
|
+
range = 'A3'
|
319
|
+
caption = sprintf(" \t_store_mso_client_anchor(%s). Cell offsets changes.", range)
|
320
|
+
data = @worksheet.substitute_cellref(range)
|
321
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test',
|
322
|
+
:x_offset=>18, :y_offset=>9)
|
323
|
+
data = data[-1]
|
324
|
+
target = %w(
|
325
|
+
00 00 10 F0 12 00
|
326
|
+
00 00 03 00 01 00 20 01 01 00 88 00 03 00 20 01
|
327
|
+
05 00 E2 00
|
328
|
+
).join(' ')
|
329
|
+
|
330
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
331
|
+
|
332
|
+
assert_equal(target, result, caption)
|
333
|
+
end
|
334
|
+
|
335
|
+
def test_for_store_mso_client_anchor_where_comment_dimensions_have_changed
|
336
|
+
# x_scale, y_scale
|
337
|
+
range = 'A3'
|
338
|
+
caption = sprintf(" \t_store_mso_client_anchor(%s). Dimensions changes.", range)
|
339
|
+
data = @worksheet.substitute_cellref(range)
|
340
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test',
|
341
|
+
:x_scale=>3, :y_scale=>2)
|
342
|
+
data = data[-1]
|
343
|
+
target = %w(
|
344
|
+
00 00 10 F0 12 00 00 00 03 00
|
345
|
+
01 00 F0 00 01 00 69 00 07 00 F0 00 0A 00 1E 00
|
346
|
+
).join(' ')
|
347
|
+
|
348
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
349
|
+
|
350
|
+
assert_equal(target, result, caption)
|
351
|
+
|
352
|
+
|
353
|
+
# width, height
|
354
|
+
data = @worksheet.substitute_cellref(range)
|
355
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test',
|
356
|
+
:width=>385, :height=>149)
|
357
|
+
data = data[-1]
|
358
|
+
target = %w(
|
359
|
+
00 00 10 F0 12 00 00 00 03 00
|
360
|
+
01 00 F0 00 01 00 69 00 07 00 F0 00 0A 00 1E 00
|
361
|
+
).join(' ')
|
362
|
+
|
363
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
364
|
+
|
365
|
+
assert_equal(target, result, caption)
|
366
|
+
|
367
|
+
end
|
368
|
+
|
369
|
+
def test_for_store_mso_client_anchor_where_column_widths_have_changed
|
370
|
+
# set_column G:G
|
371
|
+
range = 'F3'
|
372
|
+
@worksheet.set_column('G:G', 20)
|
373
|
+
|
374
|
+
caption = sprintf(" \t_store_mso_client_anchor(%s). Col width changes.", range)
|
375
|
+
data = @worksheet.substitute_cellref(range)
|
376
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
377
|
+
data = data[-1]
|
378
|
+
|
379
|
+
target = %w(
|
380
|
+
00 00 10 F0 12 00
|
381
|
+
00 00 03 00 06 00 6A 00 01 00 69 00 06 00 F2 03
|
382
|
+
05 00 C4 00
|
383
|
+
).join(' ')
|
384
|
+
|
385
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
386
|
+
|
387
|
+
assert_equal(target, result, caption)
|
388
|
+
|
389
|
+
|
390
|
+
# set_column L:O
|
391
|
+
range = 'K3'
|
392
|
+
@worksheet.set_column('L:O', 4)
|
393
|
+
|
394
|
+
data = @worksheet.substitute_cellref(range)
|
395
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
396
|
+
data = data[-1]
|
397
|
+
|
398
|
+
target = %w(
|
399
|
+
00 00 10 F0 12 00
|
400
|
+
00 00 03 00 0B 00 D1 01 01 00 69 00 0F 00 B0 00
|
401
|
+
05 00 C4 00
|
402
|
+
).join(' ')
|
403
|
+
|
404
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
405
|
+
|
406
|
+
assert_equal(target, result, caption)
|
407
|
+
|
408
|
+
end
|
409
|
+
|
410
|
+
def test_for_store_mso_client_anchor_where_row_height_have_changed
|
411
|
+
# set_row 5 to 8
|
412
|
+
range = 'A6'
|
413
|
+
@worksheet.set_row(5, 6)
|
414
|
+
@worksheet.set_row(6, 6)
|
415
|
+
@worksheet.set_row(7, 6)
|
416
|
+
@worksheet.set_row(8, 6)
|
417
|
+
|
418
|
+
caption = sprintf(" \t_store_mso_client_anchor(%s). Row height changed.", range)
|
419
|
+
data = @worksheet.substitute_cellref(range)
|
420
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
421
|
+
data = data[-1]
|
422
|
+
|
423
|
+
target = %w(
|
424
|
+
00 00 10 F0 12 00
|
425
|
+
00 00 03 00 01 00 F0 00 04 00 69 00 03 00 F0 00
|
426
|
+
0A 00 E2 00
|
427
|
+
).join(' ')
|
428
|
+
|
429
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
430
|
+
|
431
|
+
assert_equal(target, result, caption)
|
432
|
+
|
433
|
+
|
434
|
+
# set_row 14
|
435
|
+
range = 'A15'
|
436
|
+
@worksheet.set_row(14, 60)
|
437
|
+
|
438
|
+
caption = sprintf(" \t_store_mso_client_anchor(%s). Row height changed.", range)
|
439
|
+
data = @worksheet.substitute_cellref(range)
|
440
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
441
|
+
data = data[-1]
|
442
|
+
|
443
|
+
target = %w(
|
444
|
+
00 00 10 F0 12 00
|
445
|
+
00 00 03 00 01 00 F0 00 0D 00 69 00 03 00 F0 00
|
446
|
+
0E 00 CD 00
|
447
|
+
).join(' ')
|
448
|
+
|
449
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
450
|
+
|
451
|
+
assert_equal(target, result, caption)
|
452
|
+
|
453
|
+
end
|
454
|
+
|
455
|
+
def test_for_store_mso_client_data
|
456
|
+
caption = sprintf(" \t_store_mso_client_data")
|
457
|
+
target = %w(
|
458
|
+
00 00 11 F0 00 00 00 00
|
459
|
+
).join(' ')
|
460
|
+
|
461
|
+
result = unpack_record(@worksheet.store_mso_client_data)
|
462
|
+
|
463
|
+
assert_equal(target, result, caption)
|
464
|
+
end
|
465
|
+
|
466
|
+
def test_for_store_obj_comment
|
467
|
+
caption = sprintf(" \t_store_obj_comment")
|
468
|
+
data = [0x01]
|
469
|
+
target = %w(
|
470
|
+
5D 00 34 00 15 00 12 00 19 00 01 00 11 40 00 00
|
471
|
+
00 00 00 00 00 00 00 00 00 00 0D 00 16 00 00 00
|
472
|
+
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
473
|
+
00 00 00 00 00 00 00 00
|
474
|
+
).join(' ')
|
475
|
+
|
476
|
+
result = unpack_record(@worksheet.store_obj_comment(*data))
|
477
|
+
|
478
|
+
assert_equal(target, result, caption)
|
479
|
+
end
|
480
|
+
|
481
|
+
def test_for_store_mso_client_text_box
|
482
|
+
caption = sprintf(" \t_store_mso_client_text_box")
|
483
|
+
target = %w(
|
484
|
+
00 00 0D F0 00 00 00 00
|
485
|
+
).join(' ')
|
486
|
+
|
487
|
+
result = unpack_record(@worksheet.store_mso_client_text_box)
|
488
|
+
|
489
|
+
assert_equal(target, result, caption)
|
490
|
+
end
|
491
|
+
|
492
|
+
###############################################################################
|
493
|
+
#
|
494
|
+
# Unpack the binary data into a format suitable for printing in tests.
|
495
|
+
#
|
496
|
+
def unpack_record(data)
|
497
|
+
data.unpack('C*').map! {|c| sprintf("%02X", c) }.join(' ')
|
498
|
+
end
|
499
|
+
|
500
|
+
def data_for_test
|
501
|
+
return [
|
502
|
+
[ 'DggContainer', # Caption
|
503
|
+
0xF000, # Type
|
504
|
+
15, # Version
|
505
|
+
0, # Instance
|
506
|
+
'', # Data
|
507
|
+
82, # Length
|
508
|
+
'0F 00 00 F0 52 00 00 00', # Target
|
509
|
+
],
|
510
|
+
|
511
|
+
[ 'DgContainer', # Caption
|
512
|
+
0xF002, # Type
|
513
|
+
15, # Version
|
514
|
+
0, # Instance
|
515
|
+
'', # Data
|
516
|
+
328, # Length
|
517
|
+
'0F 00 02 F0 48 01 00 00', # Target
|
518
|
+
],
|
519
|
+
|
520
|
+
[ 'SpgrContainer', # Caption
|
521
|
+
0xF003, # Type
|
522
|
+
15, # Version
|
523
|
+
0, # Instance
|
524
|
+
'', # Data
|
525
|
+
304, # Length
|
526
|
+
'0F 00 03 F0 30 01 00 00', # Target
|
527
|
+
],
|
528
|
+
|
529
|
+
[ 'SpContainer', # Caption
|
530
|
+
0xF004, # Type
|
531
|
+
15, # Version
|
532
|
+
0, # Instance
|
533
|
+
'', # Data
|
534
|
+
40, # Length
|
535
|
+
'0F 00 04 F0 28 00 00 00', # Target
|
536
|
+
],
|
537
|
+
|
538
|
+
[ 'Dgg', # Caption
|
539
|
+
0xF006, # Type
|
540
|
+
0, # Version
|
541
|
+
0, # Instance
|
542
|
+
'02 04 00 00 02 00 00 00 ' + # Data
|
543
|
+
'02 00 00 00 01 00 00 00 ' +
|
544
|
+
'01 00 00 00 02 00 00 00',
|
545
|
+
nil, # Length
|
546
|
+
'00 00 06 F0 18 00 00 00 ' + # Target
|
547
|
+
'02 04 00 00 02 00 00 00 ' +
|
548
|
+
'02 00 00 00 01 00 00 00 ' +
|
549
|
+
'01 00 00 00 02 00 00 00',
|
550
|
+
],
|
551
|
+
|
552
|
+
[ 'Dg', # Caption
|
553
|
+
0xF008, # Type
|
554
|
+
0, # Version
|
555
|
+
1, # Instance
|
556
|
+
'03 00 00 00 02 04 00 00', # Data
|
557
|
+
nil, # Length
|
558
|
+
'10 00 08 F0 08 00 00 00 ' + # Target
|
559
|
+
'03 00 00 00 02 04 00 00',
|
560
|
+
],
|
561
|
+
|
562
|
+
[ 'Spgr', # Caption
|
563
|
+
0xF009, # Type
|
564
|
+
1, # Version
|
565
|
+
0, # Instance
|
566
|
+
'00 0E 00 0E 40 41 00 00 ' + # Data
|
567
|
+
'00 0E 00 0E 40 41 00 00',
|
568
|
+
nil, # Length
|
569
|
+
'01 00 09 F0 10 00 00 00 ' + # Target
|
570
|
+
'00 0E 00 0E 40 41 00 00 ' +
|
571
|
+
'00 0E 00 0E 40 41 00 00',
|
572
|
+
],
|
573
|
+
|
574
|
+
[ 'ClientTextbox', # Caption
|
575
|
+
0xF00D, # Type
|
576
|
+
0, # Version
|
577
|
+
0, # Instance
|
578
|
+
'', # Data
|
579
|
+
nil, # Length
|
580
|
+
'00 00 0D F0 00 00 00 00', # Target
|
581
|
+
],
|
582
|
+
|
583
|
+
[ 'ClientAnchor', # Caption
|
584
|
+
0xF010, # Type
|
585
|
+
0, # Version
|
586
|
+
0, # Instance
|
587
|
+
'03 00 01 00 F0 00 01 00 ' + # Data
|
588
|
+
'69 00 03 00 F0 00 05 00 ' +
|
589
|
+
'C4 00',
|
590
|
+
nil, # Length
|
591
|
+
'00 00 10 F0 12 00 00 00 ' + # Target
|
592
|
+
'03 00 01 00 F0 00 01 00 ' +
|
593
|
+
'69 00 03 00 F0 00 05 00 ' +
|
594
|
+
'C4 00',
|
595
|
+
],
|
596
|
+
|
597
|
+
[ 'ClientData', # Caption
|
598
|
+
0xF011, # Type
|
599
|
+
0, # Version
|
600
|
+
0, # Instance
|
601
|
+
'', # Data
|
602
|
+
nil, # Length
|
603
|
+
'00 00 11 F0 00 00 00 00', # Target
|
604
|
+
],
|
605
|
+
|
606
|
+
[ 'SplitMenuColors', # Caption
|
607
|
+
0xF11E, # Type
|
608
|
+
0, # Version
|
609
|
+
4, # Instance
|
610
|
+
'0D 00 00 08 0C 00 00 08 ' + # Data
|
611
|
+
'17 00 00 08 F7 00 00 10',
|
612
|
+
nil, # Length
|
613
|
+
'40 00 1E F1 10 00 00 00 ' + # Target
|
614
|
+
'0D 00 00 08 0C 00 00 08 ' +
|
615
|
+
'17 00 00 08 F7 00 00 10',
|
616
|
+
],
|
617
|
+
|
618
|
+
[ 'BstoreContainer', # Caption
|
619
|
+
0xF001, # Type
|
620
|
+
15, # Version
|
621
|
+
1, # Instance
|
622
|
+
'', # Data
|
623
|
+
163, # Length
|
624
|
+
'1F 00 01 F0 A3 00 00 00', # Target
|
625
|
+
],
|
626
|
+
]
|
627
|
+
end
|
628
|
+
|
629
|
+
end
|