writeexcel 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +26 -31
- data/examples/a_simple.rb +42 -42
- data/examples/{autofilters.rb → autofilter.rb} +264 -266
- data/examples/bigfile.rb +29 -0
- data/examples/chart_area.rb +120 -0
- data/examples/chart_bar.rb +119 -0
- data/examples/chart_column.rb +119 -0
- data/examples/chart_line.rb +119 -0
- data/examples/chart_pie.rb +107 -0
- data/examples/chart_scatter.rb +120 -0
- data/examples/chart_stock.rb +147 -0
- data/examples/copyformat.rb +51 -51
- data/examples/data_validate.rb +278 -278
- data/examples/date_time.rb +86 -86
- data/examples/defined_name.rb +31 -0
- data/examples/demo.rb +120 -118
- data/examples/diag_border.rb +35 -35
- data/examples/formats.rb +489 -489
- data/examples/header.rb +136 -136
- data/examples/hidden.rb +28 -28
- data/examples/hyperlink.rb +42 -42
- data/examples/images.rb +52 -52
- data/examples/merge1.rb +39 -39
- data/examples/merge2.rb +44 -44
- data/examples/merge3.rb +65 -65
- data/examples/merge4.rb +82 -82
- data/examples/merge5.rb +79 -79
- data/examples/properties.rb +33 -0
- data/examples/properties_jp.rb +32 -0
- data/examples/protection.rb +46 -46
- data/examples/regions.rb +52 -52
- data/examples/repeat.rb +42 -42
- data/examples/stats.rb +75 -75
- data/examples/stocks.rb +80 -80
- data/examples/tab_colors.rb +30 -30
- data/examples/write_arrays.rb +82 -0
- data/lib/writeexcel.rb +1134 -18
- data/lib/writeexcel/biffwriter.rb +273 -260
- data/lib/writeexcel/chart.rb +2306 -217
- data/lib/writeexcel/charts/area.rb +152 -0
- data/lib/writeexcel/charts/bar.rb +177 -0
- data/lib/writeexcel/charts/column.rb +156 -0
- data/lib/writeexcel/charts/external.rb +61 -0
- data/lib/writeexcel/charts/line.rb +152 -0
- data/lib/writeexcel/charts/pie.rb +169 -0
- data/lib/writeexcel/charts/scatter.rb +192 -0
- data/lib/writeexcel/charts/stock.rb +211 -0
- data/lib/writeexcel/excelformulaparser.rb +208 -195
- data/lib/writeexcel/format.rb +1697 -1108
- data/lib/writeexcel/formula.rb +1050 -986
- data/lib/writeexcel/olewriter.rb +322 -322
- data/lib/writeexcel/properties.rb +251 -250
- data/lib/writeexcel/storage_lite.rb +968 -0
- data/lib/writeexcel/workbook.rb +3294 -2630
- data/lib/writeexcel/worksheet.rb +9012 -6377
- data/test/excelfile/Chart1.xls +0 -0
- data/test/excelfile/Chart2.xls +0 -0
- data/test/excelfile/Chart3.xls +0 -0
- data/test/excelfile/Chart4.xls +0 -0
- data/test/excelfile/Chart5.xls +0 -0
- data/test/perl_output/Chart1.xls.data +0 -0
- data/test/perl_output/Chart2.xls.data +0 -0
- data/test/perl_output/Chart3.xls.data +0 -0
- data/test/perl_output/Chart4.xls.data +0 -0
- data/test/perl_output/Chart5.xls.data +0 -0
- data/test/perl_output/a_simple.xls +0 -0
- data/test/perl_output/autofilter.xls +0 -0
- data/test/perl_output/chart_area.xls +0 -0
- data/test/perl_output/chart_bar.xls +0 -0
- data/test/perl_output/chart_column.xls +0 -0
- data/test/perl_output/chart_line.xls +0 -0
- data/test/perl_output/data_validate.xls +0 -0
- data/test/perl_output/date_time.xls +0 -0
- data/test/perl_output/demo.xls +0 -0
- data/test/perl_output/demo101.bin +0 -0
- data/test/perl_output/demo201.bin +0 -0
- data/test/perl_output/demo301.bin +0 -0
- data/test/perl_output/demo401.bin +0 -0
- data/test/perl_output/demo501.bin +0 -0
- data/test/perl_output/diag_border.xls +0 -0
- data/test/perl_output/headers.xls +0 -0
- data/test/perl_output/hyperlink.xls +0 -0
- data/test/perl_output/images.xls +0 -0
- data/test/perl_output/merge1.xls +0 -0
- data/test/perl_output/merge2.xls +0 -0
- data/test/perl_output/merge3.xls +0 -0
- data/test/perl_output/merge4.xls +0 -0
- data/test/perl_output/merge5.xls +0 -0
- data/test/perl_output/protection.xls +0 -0
- data/test/perl_output/regions.xls +0 -0
- data/test/perl_output/stats.xls +0 -0
- data/test/perl_output/stocks.xls +0 -0
- data/test/perl_output/tab_colors.xls +0 -0
- data/test/perl_output/unicode_cyrillic.xls +0 -0
- data/test/perl_output/workbook1.xls +0 -0
- data/test/perl_output/workbook2.xls +0 -0
- data/test/tc_all.rb +32 -31
- data/test/tc_biff.rb +104 -104
- data/test/tc_chart.rb +22 -22
- data/test/tc_example_match.rb +1944 -1280
- data/test/tc_format.rb +1254 -1267
- data/test/tc_formula.rb +63 -63
- data/test/tc_ole.rb +110 -110
- data/test/tc_storage_lite.rb +149 -0
- data/test/tc_workbook.rb +140 -115
- data/test/tc_worksheet.rb +115 -115
- data/test/test_00_IEEE_double.rb +14 -14
- data/test/test_01_add_worksheet.rb +12 -12
- data/test/test_02_merge_formats.rb +58 -58
- data/test/test_04_dimensions.rb +397 -397
- data/test/test_05_rows.rb +182 -182
- data/test/test_06_extsst.rb +80 -80
- data/test/test_11_date_time.rb +484 -484
- data/test/test_12_date_only.rb +506 -506
- data/test/test_13_date_seconds.rb +486 -486
- data/test/test_21_escher.rb +642 -629
- data/test/test_22_mso_drawing_group.rb +750 -739
- data/test/test_23_note.rb +78 -78
- data/test/test_24_txo.rb +80 -80
- data/test/test_25_position_object.rb +82 -0
- data/test/test_26_autofilter.rb +327 -327
- data/test/test_27_autofilter.rb +144 -144
- data/test/test_28_autofilter.rb +174 -174
- data/test/test_29_process_jpg.rb +681 -131
- data/test/test_30_validation_dval.rb +82 -82
- data/test/test_31_validation_dv_strings.rb +131 -131
- data/test/test_32_validation_dv_formula.rb +211 -211
- data/test/test_40_property_types.rb +191 -191
- data/test/test_41_properties.rb +238 -238
- data/test/test_42_set_properties.rb +442 -419
- data/test/test_50_name_stored.rb +305 -0
- data/test/test_51_name_print_area.rb +363 -0
- data/test/test_52_name_print_titles.rb +460 -0
- data/test/test_53_autofilter.rb +209 -0
- data/test/test_60_chart_generic.rb +576 -0
- data/test/test_61_chart_subclasses.rb +97 -0
- data/test/test_62_chart_formats.rb +270 -0
- data/test/test_63_chart_area_formats.rb +647 -0
- data/test/test_chartex.rb +35 -0
- data/test/ts_all.rb +46 -34
- data/writeexcel.gemspec +18 -0
- data/writeexcel.rdoc +583 -0
- metadata +162 -108
@@ -1,419 +1,442 @@
|
|
1
|
-
##########################################################################
|
2
|
-
# test_42_set_properties.rb
|
3
|
-
#
|
4
|
-
# Tests for Workbook property_sets() interface.
|
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
|
-
target
|
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
|
-
# Test
|
122
|
-
#
|
123
|
-
|
124
|
-
workbook.set_properties(
|
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
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
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
|
-
|
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
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
1
|
+
##########################################################################
|
2
|
+
# test_42_set_properties.rb
|
3
|
+
#
|
4
|
+
# Tests for Workbook property_sets() interface.
|
5
|
+
#
|
6
|
+
# some test is commented out because related method was set to
|
7
|
+
# private method. Before that, all test passed.
|
8
|
+
#
|
9
|
+
#
|
10
|
+
#
|
11
|
+
#
|
12
|
+
# reverse('©'), September 2005, John McNamara, jmcnamara@cpan.org
|
13
|
+
#
|
14
|
+
# original written in Perl by John McNamara
|
15
|
+
# converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
|
16
|
+
#
|
17
|
+
#########################################################################
|
18
|
+
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
|
19
|
+
|
20
|
+
require 'test/unit'
|
21
|
+
require 'rubygems'
|
22
|
+
require 'writeexcel'
|
23
|
+
|
24
|
+
class TC_set_properties < Test::Unit::TestCase
|
25
|
+
|
26
|
+
def test_dummy
|
27
|
+
assert(true)
|
28
|
+
end
|
29
|
+
|
30
|
+
def setup
|
31
|
+
t = Time.now.strftime("%Y%m%d")
|
32
|
+
path = "temp#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
|
33
|
+
@test_file = File.join(Dir.tmpdir, path)
|
34
|
+
end
|
35
|
+
|
36
|
+
def teardown
|
37
|
+
File.unlink(@test_file) if FileTest.exist?(@test_file)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_same_as_previous_plus_creation_date
|
41
|
+
smiley = '☺' # chr 0x263A; in perl
|
42
|
+
|
43
|
+
workbook = WriteExcel.new(@test_file)
|
44
|
+
worksheet = workbook.add_worksheet
|
45
|
+
|
46
|
+
=begin
|
47
|
+
###############################################################################
|
48
|
+
#
|
49
|
+
# Test 1. _get_property_set_codepage() for default latin1 strings.
|
50
|
+
#
|
51
|
+
params ={
|
52
|
+
:title => 'Title',
|
53
|
+
:subject => 'Subject',
|
54
|
+
:author => 'Author',
|
55
|
+
:keywords => 'Keywords',
|
56
|
+
:comments => 'Comments',
|
57
|
+
:last_author => 'Username',
|
58
|
+
}
|
59
|
+
|
60
|
+
strings = %w(title subject author keywords comments last_author)
|
61
|
+
|
62
|
+
caption = " \t_get_property_set_codepage('latin1')"
|
63
|
+
target = 0x04E4
|
64
|
+
|
65
|
+
result = workbook.get_property_set_codepage(params, strings)
|
66
|
+
assert_equal(target, result, caption)
|
67
|
+
|
68
|
+
###############################################################################
|
69
|
+
#
|
70
|
+
# Test 2. _get_property_set_codepage() for manual utf8 strings.
|
71
|
+
#
|
72
|
+
|
73
|
+
params = {
|
74
|
+
:title => 'Title',
|
75
|
+
:subject => 'Subject',
|
76
|
+
:author => 'Author',
|
77
|
+
:keywords => 'Keywords',
|
78
|
+
:comments => 'Comments',
|
79
|
+
:last_author => 'Username',
|
80
|
+
:utf8 => 1,
|
81
|
+
}
|
82
|
+
|
83
|
+
strings = %w(title subject author keywords comments last_author)
|
84
|
+
|
85
|
+
caption = " \t_get_property_set_codepage('utf8')"
|
86
|
+
target = 0xFDE9
|
87
|
+
|
88
|
+
result = workbook.get_property_set_codepage(params, strings)
|
89
|
+
assert_equal(target, result, caption)
|
90
|
+
|
91
|
+
###############################################################################
|
92
|
+
#
|
93
|
+
# Test 3. _get_property_set_codepage() for perl 5.8 utf8 strings.
|
94
|
+
#
|
95
|
+
params = {
|
96
|
+
:title => 'Title' + smiley,
|
97
|
+
:subject => 'Subject',
|
98
|
+
:author => 'Author',
|
99
|
+
:keywords => 'Keywords',
|
100
|
+
:comments => 'Comments',
|
101
|
+
:last_author => 'Username',
|
102
|
+
}
|
103
|
+
|
104
|
+
strings = %w(title subject author keywords comments last_author)
|
105
|
+
|
106
|
+
caption = " \t_get_property_set_codepage('utf8')";
|
107
|
+
target = 0xFDE9;
|
108
|
+
|
109
|
+
result = workbook.get_property_set_codepage(params, strings)
|
110
|
+
assert_equal(target, result, caption)
|
111
|
+
=end
|
112
|
+
|
113
|
+
###############################################################################
|
114
|
+
#
|
115
|
+
# Note, the "created => nil" parameters in some of the following tests is
|
116
|
+
# used to avoid adding the default date to the property sets.
|
117
|
+
|
118
|
+
|
119
|
+
###############################################################################
|
120
|
+
#
|
121
|
+
# Test 4. Codepage only.
|
122
|
+
#
|
123
|
+
|
124
|
+
workbook.set_properties(
|
125
|
+
:created => nil
|
126
|
+
)
|
127
|
+
|
128
|
+
caption = " \tset_properties(codepage)"
|
129
|
+
target = %w(
|
130
|
+
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
131
|
+
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
132
|
+
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
133
|
+
18 00 00 00 01 00 00 00 01 00 00 00 10 00 00 00
|
134
|
+
02 00 00 00 E4 04 00 00
|
135
|
+
).join(' ')
|
136
|
+
|
137
|
+
result = unpack_record( workbook.summary )
|
138
|
+
assert_equal(target, result, caption)
|
139
|
+
|
140
|
+
###############################################################################
|
141
|
+
#
|
142
|
+
# Test 5. Same as previous + Title.
|
143
|
+
#
|
144
|
+
|
145
|
+
workbook.set_properties(
|
146
|
+
:title => 'Title',
|
147
|
+
:created => nil
|
148
|
+
)
|
149
|
+
|
150
|
+
caption = " \tset_properties('Title')"
|
151
|
+
target = %w(
|
152
|
+
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
153
|
+
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
154
|
+
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
155
|
+
30 00 00 00 02 00 00 00 01 00 00 00 18 00 00 00
|
156
|
+
02 00 00 00 20 00 00 00 02 00 00 00 E4 04 00 00
|
157
|
+
1E 00 00 00 06 00 00 00 54 69 74 6C 65 00 00 00
|
158
|
+
).join(' ')
|
159
|
+
|
160
|
+
result = unpack_record( workbook.summary )
|
161
|
+
assert_equal(target, result, caption)
|
162
|
+
|
163
|
+
###############################################################################
|
164
|
+
#
|
165
|
+
# Test 6. Same as previous + Subject.
|
166
|
+
#
|
167
|
+
|
168
|
+
workbook.set_properties(
|
169
|
+
:title => 'Title',
|
170
|
+
:subject => 'Subject',
|
171
|
+
:created => nil
|
172
|
+
)
|
173
|
+
|
174
|
+
caption = " \tset_properties('+ Subject')"
|
175
|
+
target = %w(
|
176
|
+
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
177
|
+
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
178
|
+
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
179
|
+
48 00 00 00 03 00 00 00 01 00 00 00 20 00 00 00
|
180
|
+
02 00 00 00 28 00 00 00 03 00 00 00 38 00 00 00
|
181
|
+
02 00 00 00 E4 04 00 00 1E 00 00 00 06 00 00 00
|
182
|
+
54 69 74 6C 65 00 00 00 1E 00 00 00 08 00 00 00
|
183
|
+
53 75 62 6A 65 63 74 00
|
184
|
+
).join(' ')
|
185
|
+
|
186
|
+
result = unpack_record( workbook.summary )
|
187
|
+
assert_equal(target, result, caption)
|
188
|
+
|
189
|
+
###############################################################################
|
190
|
+
#
|
191
|
+
# Test 7. Same as previous + Author.
|
192
|
+
#
|
193
|
+
|
194
|
+
workbook.set_properties(
|
195
|
+
:title => 'Title',
|
196
|
+
:subject => 'Subject',
|
197
|
+
:author => 'Author',
|
198
|
+
:created => nil
|
199
|
+
)
|
200
|
+
|
201
|
+
caption = " \tset_properties('+ Author')"
|
202
|
+
target = %w(
|
203
|
+
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
204
|
+
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
205
|
+
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
206
|
+
60 00 00 00 04 00 00 00 01 00 00 00 28 00 00 00
|
207
|
+
02 00 00 00 30 00 00 00 03 00 00 00 40 00 00 00
|
208
|
+
04 00 00 00 50 00 00 00 02 00 00 00 E4 04 00 00
|
209
|
+
1E 00 00 00 06 00 00 00 54 69 74 6C 65 00 00 00
|
210
|
+
1E 00 00 00 08 00 00 00 53 75 62 6A 65 63 74 00
|
211
|
+
1E 00 00 00 07 00 00 00 41 75 74 68 6F 72 00 00
|
212
|
+
).join(' ')
|
213
|
+
|
214
|
+
result = unpack_record( workbook.summary )
|
215
|
+
assert_equal(target, result, caption)
|
216
|
+
|
217
|
+
###############################################################################
|
218
|
+
#
|
219
|
+
# Test 8. Same as previous + Keywords.
|
220
|
+
#
|
221
|
+
|
222
|
+
workbook.set_properties(
|
223
|
+
:title => 'Title',
|
224
|
+
:subject => 'Subject',
|
225
|
+
:author => 'Author',
|
226
|
+
:keywords => 'Keywords',
|
227
|
+
:created => nil
|
228
|
+
)
|
229
|
+
|
230
|
+
caption = " \tset_properties('+ Keywords')"
|
231
|
+
target = %w(
|
232
|
+
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
233
|
+
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
234
|
+
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
235
|
+
7C 00 00 00 05 00 00 00 01 00 00 00 30 00 00 00
|
236
|
+
02 00 00 00 38 00 00 00 03 00 00 00 48 00 00 00
|
237
|
+
04 00 00 00 58 00 00 00 05 00 00 00 68 00 00 00
|
238
|
+
02 00 00 00 E4 04 00 00 1E 00 00 00 06 00 00 00
|
239
|
+
54 69 74 6C 65 00 00 00 1E 00 00 00 08 00 00 00
|
240
|
+
53 75 62 6A 65 63 74 00 1E 00 00 00 07 00 00 00
|
241
|
+
41 75 74 68 6F 72 00 00 1E 00 00 00 09 00 00 00
|
242
|
+
4B 65 79 77 6F 72 64 73 00 00 00 00
|
243
|
+
).join(' ')
|
244
|
+
|
245
|
+
result = unpack_record( workbook.summary )
|
246
|
+
assert_equal(target, result, caption)
|
247
|
+
|
248
|
+
###############################################################################
|
249
|
+
#
|
250
|
+
# Test 9. Same as previous + Comments.
|
251
|
+
#
|
252
|
+
|
253
|
+
workbook.set_properties(
|
254
|
+
:title => 'Title',
|
255
|
+
:subject => 'Subject',
|
256
|
+
:author => 'Author',
|
257
|
+
:keywords => 'Keywords',
|
258
|
+
:comments => 'Comments',
|
259
|
+
:created => nil
|
260
|
+
)
|
261
|
+
|
262
|
+
caption = " \tset_properties('+ Comments')"
|
263
|
+
target = %w(
|
264
|
+
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
265
|
+
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
266
|
+
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
267
|
+
98 00 00 00 06 00 00 00 01 00 00 00 38 00 00 00
|
268
|
+
02 00 00 00 40 00 00 00 03 00 00 00 50 00 00 00
|
269
|
+
04 00 00 00 60 00 00 00 05 00 00 00 70 00 00 00
|
270
|
+
06 00 00 00 84 00 00 00 02 00 00 00 E4 04 00 00
|
271
|
+
1E 00 00 00 06 00 00 00 54 69 74 6C 65 00 00 00
|
272
|
+
1E 00 00 00 08 00 00 00 53 75 62 6A 65 63 74 00
|
273
|
+
1E 00 00 00 07 00 00 00 41 75 74 68 6F 72 00 00
|
274
|
+
1E 00 00 00 09 00 00 00 4B 65 79 77 6F 72 64 73
|
275
|
+
00 00 00 00 1E 00 00 00 09 00 00 00 43 6F 6D 6D
|
276
|
+
65 6E 74 73 00 00 00 00
|
277
|
+
).join(' ')
|
278
|
+
|
279
|
+
result = unpack_record( workbook.summary )
|
280
|
+
assert_equal(target, result, caption)
|
281
|
+
|
282
|
+
###############################################################################
|
283
|
+
#
|
284
|
+
# Test 10. Same as previous + Last author.
|
285
|
+
#
|
286
|
+
|
287
|
+
workbook.set_properties(
|
288
|
+
:title => 'Title',
|
289
|
+
:subject => 'Subject',
|
290
|
+
:author => 'Author',
|
291
|
+
:keywords => 'Keywords',
|
292
|
+
:comments => 'Comments',
|
293
|
+
:last_author => 'Username',
|
294
|
+
:created => nil
|
295
|
+
)
|
296
|
+
|
297
|
+
caption = " \tset_properties('+ Last author')"
|
298
|
+
target = %w(
|
299
|
+
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
300
|
+
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
301
|
+
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
302
|
+
B4 00 00 00 07 00 00 00 01 00 00 00 40 00 00 00
|
303
|
+
02 00 00 00 48 00 00 00 03 00 00 00 58 00 00 00
|
304
|
+
04 00 00 00 68 00 00 00 05 00 00 00 78 00 00 00
|
305
|
+
06 00 00 00 8C 00 00 00 08 00 00 00 A0 00 00 00
|
306
|
+
02 00 00 00 E4 04 00 00 1E 00 00 00 06 00 00 00
|
307
|
+
54 69 74 6C 65 00 00 00 1E 00 00 00 08 00 00 00
|
308
|
+
53 75 62 6A 65 63 74 00 1E 00 00 00 07 00 00 00
|
309
|
+
41 75 74 68 6F 72 00 00 1E 00 00 00 09 00 00 00
|
310
|
+
4B 65 79 77 6F 72 64 73 00 00 00 00 1E 00 00 00
|
311
|
+
09 00 00 00 43 6F 6D 6D 65 6E 74 73 00 00 00 00
|
312
|
+
1E 00 00 00 09 00 00 00 55 73 65 72 6E 61 6D 65
|
313
|
+
00 00 00 00
|
314
|
+
).join(' ')
|
315
|
+
|
316
|
+
result = unpack_record( workbook.summary )
|
317
|
+
assert_equal(target, result, caption)
|
318
|
+
|
319
|
+
###############################################################################
|
320
|
+
#
|
321
|
+
# Test 11. Same as previous + Creation date.
|
322
|
+
#
|
323
|
+
|
324
|
+
# Aug 19 23:20:13 2008
|
325
|
+
# $sec,$min,$hour,$mday,$mon,$year
|
326
|
+
# We normalise the time using timegm() so that the tests don't fail due to
|
327
|
+
# different timezones.
|
328
|
+
|
329
|
+
filetime = Time.gm(2008,8,19,23,20,13)
|
330
|
+
workbook.set_properties(
|
331
|
+
:title => 'Title',
|
332
|
+
:subject => 'Subject',
|
333
|
+
:author => 'Author',
|
334
|
+
:keywords => 'Keywords',
|
335
|
+
:comments => 'Comments',
|
336
|
+
:last_author => 'Username',
|
337
|
+
:created => filetime
|
338
|
+
)
|
339
|
+
|
340
|
+
caption = " \tset_properties('+ Creation date')"
|
341
|
+
target = %w(
|
342
|
+
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
343
|
+
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
344
|
+
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
345
|
+
C8 00 00 00 08 00 00 00 01 00 00 00 48 00 00 00
|
346
|
+
02 00 00 00 50 00 00 00 03 00 00 00 60 00 00 00
|
347
|
+
04 00 00 00 70 00 00 00 05 00 00 00 80 00 00 00
|
348
|
+
06 00 00 00 94 00 00 00 08 00 00 00 A8 00 00 00
|
349
|
+
0C 00 00 00 BC 00 00 00 02 00 00 00 E4 04 00 00
|
350
|
+
1E 00 00 00 06 00 00 00 54 69 74 6C 65 00 00 00
|
351
|
+
1E 00 00 00 08 00 00 00 53 75 62 6A 65 63 74 00
|
352
|
+
1E 00 00 00 07 00 00 00 41 75 74 68 6F 72 00 00
|
353
|
+
1E 00 00 00 09 00 00 00 4B 65 79 77 6F 72 64 73
|
354
|
+
00 00 00 00 1E 00 00 00 09 00 00 00 43 6F 6D 6D
|
355
|
+
65 6E 74 73 00 00 00 00 1E 00 00 00 09 00 00 00
|
356
|
+
55 73 65 72 6E 61 6D 65 00 00 00 00 40 00 00 00
|
357
|
+
80 74 89 21 52 02 C9 01
|
358
|
+
).join(' ')
|
359
|
+
|
360
|
+
result = unpack_record( workbook.summary )
|
361
|
+
assert_equal(target, result, caption)
|
362
|
+
|
363
|
+
###############################################################################
|
364
|
+
#
|
365
|
+
# Test 12. Same as previous. Date set at the workbook level.
|
366
|
+
#
|
367
|
+
|
368
|
+
# Wed Aug 20 00:20:13 2008
|
369
|
+
# $sec,$min,$hour,$mday,$mon,$year
|
370
|
+
# We normalise the time using timegm() so that the tests don't fail due to
|
371
|
+
# different timezones.
|
372
|
+
workbook.localtime = Time.gm(2008,8,19,23,20,13)
|
373
|
+
|
374
|
+
workbook.set_properties(
|
375
|
+
:title => 'Title',
|
376
|
+
:subject => 'Subject',
|
377
|
+
:author => 'Author',
|
378
|
+
:keywords => 'Keywords',
|
379
|
+
:comments => 'Comments',
|
380
|
+
:last_author => 'Username'
|
381
|
+
)
|
382
|
+
|
383
|
+
caption = " \tset_properties('+ Creation date')"
|
384
|
+
target = %w(
|
385
|
+
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
386
|
+
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
387
|
+
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
388
|
+
C8 00 00 00 08 00 00 00 01 00 00 00 48 00 00 00
|
389
|
+
02 00 00 00 50 00 00 00 03 00 00 00 60 00 00 00
|
390
|
+
04 00 00 00 70 00 00 00 05 00 00 00 80 00 00 00
|
391
|
+
06 00 00 00 94 00 00 00 08 00 00 00 A8 00 00 00
|
392
|
+
0C 00 00 00 BC 00 00 00 02 00 00 00 E4 04 00 00
|
393
|
+
1E 00 00 00 06 00 00 00 54 69 74 6C 65 00 00 00
|
394
|
+
1E 00 00 00 08 00 00 00 53 75 62 6A 65 63 74 00
|
395
|
+
1E 00 00 00 07 00 00 00 41 75 74 68 6F 72 00 00
|
396
|
+
1E 00 00 00 09 00 00 00 4B 65 79 77 6F 72 64 73
|
397
|
+
00 00 00 00 1E 00 00 00 09 00 00 00 43 6F 6D 6D
|
398
|
+
65 6E 74 73 00 00 00 00 1E 00 00 00 09 00 00 00
|
399
|
+
55 73 65 72 6E 61 6D 65 00 00 00 00 40 00 00 00
|
400
|
+
80 74 89 21 52 02 C9 01
|
401
|
+
).join(' ')
|
402
|
+
|
403
|
+
result = unpack_record( workbook.summary )
|
404
|
+
assert_equal(target, result, caption)
|
405
|
+
|
406
|
+
###############################################################################
|
407
|
+
#
|
408
|
+
# Test 14. UTF-8 string used.
|
409
|
+
#
|
410
|
+
|
411
|
+
workbook.set_properties(
|
412
|
+
:title => 'Title' + smiley,
|
413
|
+
:created => nil
|
414
|
+
)
|
415
|
+
|
416
|
+
caption = " \tset_properties(utf8)"
|
417
|
+
target = %w(
|
418
|
+
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
419
|
+
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
420
|
+
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
421
|
+
34 00 00 00 02 00 00 00 01 00 00 00 18 00 00 00
|
422
|
+
02 00 00 00 20 00 00 00 02 00 00 00 E9 FD 00 00
|
423
|
+
1E 00 00 00 09 00 00 00 54 69 74 6C 65 E2 98 BA
|
424
|
+
00 00 00 00
|
425
|
+
).join(' ')
|
426
|
+
|
427
|
+
result = unpack_record( workbook.summary )
|
428
|
+
assert_equal(target, result, caption)
|
429
|
+
|
430
|
+
workbook.close
|
431
|
+
|
432
|
+
end
|
433
|
+
|
434
|
+
###############################################################################
|
435
|
+
#
|
436
|
+
# Unpack the binary data into a format suitable for printing in tests.
|
437
|
+
#
|
438
|
+
def unpack_record(data)
|
439
|
+
data.unpack('C*').map! {|c| sprintf("%02X", c) }.join(' ')
|
440
|
+
end
|
441
|
+
|
442
|
+
end
|