writeexcel 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +103 -0
- data/examples/a_simple.rb +42 -0
- data/examples/autofilters.rb +266 -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/republic.png +0 -0
- data/examples/stats.rb +75 -0
- data/examples/stocks.rb +80 -0
- data/examples/tab_colors.rb +30 -0
- data/lib/writeexcel/biffwriter.rb +260 -0
- data/lib/writeexcel/chart.rb +217 -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/workbook.rb +2630 -0
- data/lib/writeexcel/worksheet.rb +6377 -0
- data/lib/writeexcel.rb +18 -0
- data/test/perl_output/README +31 -0
- data/test/perl_output/a_simple.xls +0 -0
- data/test/perl_output/biff_add_continue_testdata +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/diag_border.xls +0 -0
- data/test/perl_output/f_font_biff +0 -0
- data/test/perl_output/f_font_key +1 -0
- data/test/perl_output/f_xf_biff +0 -0
- data/test/perl_output/file_font_biff +0 -0
- data/test/perl_output/file_font_key +1 -0
- data/test/perl_output/file_xf_biff +0 -0
- data/test/perl_output/headers.xls +0 -0
- data/test/perl_output/hidden.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/ole_write_header +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/perl_output/ws_colinfo +1 -0
- data/test/perl_output/ws_store_colinfo +0 -0
- data/test/perl_output/ws_store_dimensions +0 -0
- data/test/perl_output/ws_store_filtermode +0 -0
- data/test/perl_output/ws_store_filtermode_off +0 -0
- data/test/perl_output/ws_store_filtermode_on +0 -0
- data/test/perl_output/ws_store_selection +0 -0
- data/test/perl_output/ws_store_window2 +1 -0
- data/test/republic.png +0 -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 +1267 -0
- data/test/tc_formula.rb +63 -0
- data/test/tc_ole.rb +110 -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 +419 -0
- data/test/ts_all.rb +34 -0
- metadata +170 -0
@@ -0,0 +1,419 @@
|
|
1
|
+
##########################################################################
|
2
|
+
# test_42_set_properties.rb
|
3
|
+
#
|
4
|
+
# Tests for Workbook property_sets() interface.
|
5
|
+
#
|
6
|
+
# reverse('©'), September 2005, John McNamara, jmcnamara@cpan.org
|
7
|
+
#
|
8
|
+
# original written in Perl by John McNamara
|
9
|
+
# converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
|
10
|
+
#
|
11
|
+
#########################################################################
|
12
|
+
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
|
13
|
+
|
14
|
+
require 'test/unit'
|
15
|
+
require 'rubygems'
|
16
|
+
require 'writeexcel'
|
17
|
+
|
18
|
+
class TC_set_properties < Test::Unit::TestCase
|
19
|
+
|
20
|
+
def test_same_as_previous_plus_creation_date
|
21
|
+
test_file = 'temp_test_file.xls'
|
22
|
+
smiley = '☺' # chr 0x263A; in perl
|
23
|
+
|
24
|
+
workbook = Spreadsheet::WriteExcel.new(test_file)
|
25
|
+
worksheet = workbook.add_worksheet
|
26
|
+
|
27
|
+
###############################################################################
|
28
|
+
#
|
29
|
+
# Test 1. _get_property_set_codepage() for default latin1 strings.
|
30
|
+
#
|
31
|
+
params ={
|
32
|
+
:title => 'Title',
|
33
|
+
:subject => 'Subject',
|
34
|
+
:author => 'Author',
|
35
|
+
:keywords => 'Keywords',
|
36
|
+
:comments => 'Comments',
|
37
|
+
:last_author => 'Username',
|
38
|
+
}
|
39
|
+
|
40
|
+
strings = %w(title subject author keywords comments last_author)
|
41
|
+
|
42
|
+
caption = " \t_get_property_set_codepage('latin1')"
|
43
|
+
target = 0x04E4
|
44
|
+
|
45
|
+
result = workbook.get_property_set_codepage(params, strings)
|
46
|
+
assert_equal(target, result, caption)
|
47
|
+
|
48
|
+
###############################################################################
|
49
|
+
#
|
50
|
+
# Test 2. _get_property_set_codepage() for manual utf8 strings.
|
51
|
+
#
|
52
|
+
|
53
|
+
params = {
|
54
|
+
:title => 'Title',
|
55
|
+
:subject => 'Subject',
|
56
|
+
:author => 'Author',
|
57
|
+
:keywords => 'Keywords',
|
58
|
+
:comments => 'Comments',
|
59
|
+
:last_author => 'Username',
|
60
|
+
:utf8 => 1,
|
61
|
+
}
|
62
|
+
|
63
|
+
strings = %w(title subject author keywords comments last_author)
|
64
|
+
|
65
|
+
caption = " \t_get_property_set_codepage('utf8')"
|
66
|
+
target = 0xFDE9
|
67
|
+
|
68
|
+
result = workbook.get_property_set_codepage(params, strings)
|
69
|
+
assert_equal(target, result, caption)
|
70
|
+
|
71
|
+
###############################################################################
|
72
|
+
#
|
73
|
+
# Test 3. _get_property_set_codepage() for perl 5.8 utf8 strings.
|
74
|
+
#
|
75
|
+
params = {
|
76
|
+
:title => 'Title' + smiley,
|
77
|
+
:subject => 'Subject',
|
78
|
+
:author => 'Author',
|
79
|
+
:keywords => 'Keywords',
|
80
|
+
:comments => 'Comments',
|
81
|
+
:last_author => 'Username',
|
82
|
+
}
|
83
|
+
|
84
|
+
strings = %w(title subject author keywords comments last_author)
|
85
|
+
|
86
|
+
caption = " \t_get_property_set_codepage('utf8')";
|
87
|
+
target = 0xFDE9;
|
88
|
+
|
89
|
+
result = workbook.get_property_set_codepage(params, strings)
|
90
|
+
assert_equal(target, result, caption)
|
91
|
+
|
92
|
+
###############################################################################
|
93
|
+
#
|
94
|
+
# Note, the "created => nil" parameters in some of the following tests is
|
95
|
+
# used to avoid adding the default date to the property sets.
|
96
|
+
|
97
|
+
|
98
|
+
###############################################################################
|
99
|
+
#
|
100
|
+
# Test 4. Codepage only.
|
101
|
+
#
|
102
|
+
|
103
|
+
workbook.set_properties(
|
104
|
+
:created => nil
|
105
|
+
)
|
106
|
+
|
107
|
+
caption = " \tset_properties(codepage)"
|
108
|
+
target = %w(
|
109
|
+
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
110
|
+
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
111
|
+
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
112
|
+
18 00 00 00 01 00 00 00 01 00 00 00 10 00 00 00
|
113
|
+
02 00 00 00 E4 04 00 00
|
114
|
+
).join(' ')
|
115
|
+
|
116
|
+
result = unpack_record( workbook.summary )
|
117
|
+
assert_equal(target, result, caption)
|
118
|
+
|
119
|
+
###############################################################################
|
120
|
+
#
|
121
|
+
# Test 5. Same as previous + Title.
|
122
|
+
#
|
123
|
+
|
124
|
+
workbook.set_properties(
|
125
|
+
:title => 'Title',
|
126
|
+
:created => nil
|
127
|
+
)
|
128
|
+
|
129
|
+
caption = " \tset_properties('Title')"
|
130
|
+
target = %w(
|
131
|
+
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
132
|
+
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
133
|
+
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
134
|
+
30 00 00 00 02 00 00 00 01 00 00 00 18 00 00 00
|
135
|
+
02 00 00 00 20 00 00 00 02 00 00 00 E4 04 00 00
|
136
|
+
1E 00 00 00 06 00 00 00 54 69 74 6C 65 00 00 00
|
137
|
+
).join(' ')
|
138
|
+
|
139
|
+
result = unpack_record( workbook.summary )
|
140
|
+
assert_equal(target, result, caption)
|
141
|
+
|
142
|
+
###############################################################################
|
143
|
+
#
|
144
|
+
# Test 6. Same as previous + Subject.
|
145
|
+
#
|
146
|
+
|
147
|
+
workbook.set_properties(
|
148
|
+
:title => 'Title',
|
149
|
+
:subject => 'Subject',
|
150
|
+
:created => nil
|
151
|
+
)
|
152
|
+
|
153
|
+
caption = " \tset_properties('+ Subject')"
|
154
|
+
target = %w(
|
155
|
+
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
156
|
+
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
157
|
+
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
158
|
+
48 00 00 00 03 00 00 00 01 00 00 00 20 00 00 00
|
159
|
+
02 00 00 00 28 00 00 00 03 00 00 00 38 00 00 00
|
160
|
+
02 00 00 00 E4 04 00 00 1E 00 00 00 06 00 00 00
|
161
|
+
54 69 74 6C 65 00 00 00 1E 00 00 00 08 00 00 00
|
162
|
+
53 75 62 6A 65 63 74 00
|
163
|
+
).join(' ')
|
164
|
+
|
165
|
+
result = unpack_record( workbook.summary )
|
166
|
+
assert_equal(target, result, caption)
|
167
|
+
|
168
|
+
###############################################################################
|
169
|
+
#
|
170
|
+
# Test 7. Same as previous + Author.
|
171
|
+
#
|
172
|
+
|
173
|
+
workbook.set_properties(
|
174
|
+
:title => 'Title',
|
175
|
+
:subject => 'Subject',
|
176
|
+
:author => 'Author',
|
177
|
+
:created => nil
|
178
|
+
)
|
179
|
+
|
180
|
+
caption = " \tset_properties('+ Author')"
|
181
|
+
target = %w(
|
182
|
+
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
183
|
+
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
184
|
+
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
185
|
+
60 00 00 00 04 00 00 00 01 00 00 00 28 00 00 00
|
186
|
+
02 00 00 00 30 00 00 00 03 00 00 00 40 00 00 00
|
187
|
+
04 00 00 00 50 00 00 00 02 00 00 00 E4 04 00 00
|
188
|
+
1E 00 00 00 06 00 00 00 54 69 74 6C 65 00 00 00
|
189
|
+
1E 00 00 00 08 00 00 00 53 75 62 6A 65 63 74 00
|
190
|
+
1E 00 00 00 07 00 00 00 41 75 74 68 6F 72 00 00
|
191
|
+
).join(' ')
|
192
|
+
|
193
|
+
result = unpack_record( workbook.summary )
|
194
|
+
assert_equal(target, result, caption)
|
195
|
+
|
196
|
+
###############################################################################
|
197
|
+
#
|
198
|
+
# Test 8. Same as previous + Keywords.
|
199
|
+
#
|
200
|
+
|
201
|
+
workbook.set_properties(
|
202
|
+
:title => 'Title',
|
203
|
+
:subject => 'Subject',
|
204
|
+
:author => 'Author',
|
205
|
+
:keywords => 'Keywords',
|
206
|
+
:created => nil
|
207
|
+
)
|
208
|
+
|
209
|
+
caption = " \tset_properties('+ Keywords')"
|
210
|
+
target = %w(
|
211
|
+
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
212
|
+
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
213
|
+
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
214
|
+
7C 00 00 00 05 00 00 00 01 00 00 00 30 00 00 00
|
215
|
+
02 00 00 00 38 00 00 00 03 00 00 00 48 00 00 00
|
216
|
+
04 00 00 00 58 00 00 00 05 00 00 00 68 00 00 00
|
217
|
+
02 00 00 00 E4 04 00 00 1E 00 00 00 06 00 00 00
|
218
|
+
54 69 74 6C 65 00 00 00 1E 00 00 00 08 00 00 00
|
219
|
+
53 75 62 6A 65 63 74 00 1E 00 00 00 07 00 00 00
|
220
|
+
41 75 74 68 6F 72 00 00 1E 00 00 00 09 00 00 00
|
221
|
+
4B 65 79 77 6F 72 64 73 00 00 00 00
|
222
|
+
).join(' ')
|
223
|
+
|
224
|
+
result = unpack_record( workbook.summary )
|
225
|
+
assert_equal(target, result, caption)
|
226
|
+
|
227
|
+
###############################################################################
|
228
|
+
#
|
229
|
+
# Test 9. Same as previous + Comments.
|
230
|
+
#
|
231
|
+
|
232
|
+
workbook.set_properties(
|
233
|
+
:title => 'Title',
|
234
|
+
:subject => 'Subject',
|
235
|
+
:author => 'Author',
|
236
|
+
:keywords => 'Keywords',
|
237
|
+
:comments => 'Comments',
|
238
|
+
:created => nil
|
239
|
+
)
|
240
|
+
|
241
|
+
caption = " \tset_properties('+ Comments')"
|
242
|
+
target = %w(
|
243
|
+
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
244
|
+
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
245
|
+
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
246
|
+
98 00 00 00 06 00 00 00 01 00 00 00 38 00 00 00
|
247
|
+
02 00 00 00 40 00 00 00 03 00 00 00 50 00 00 00
|
248
|
+
04 00 00 00 60 00 00 00 05 00 00 00 70 00 00 00
|
249
|
+
06 00 00 00 84 00 00 00 02 00 00 00 E4 04 00 00
|
250
|
+
1E 00 00 00 06 00 00 00 54 69 74 6C 65 00 00 00
|
251
|
+
1E 00 00 00 08 00 00 00 53 75 62 6A 65 63 74 00
|
252
|
+
1E 00 00 00 07 00 00 00 41 75 74 68 6F 72 00 00
|
253
|
+
1E 00 00 00 09 00 00 00 4B 65 79 77 6F 72 64 73
|
254
|
+
00 00 00 00 1E 00 00 00 09 00 00 00 43 6F 6D 6D
|
255
|
+
65 6E 74 73 00 00 00 00
|
256
|
+
).join(' ')
|
257
|
+
|
258
|
+
result = unpack_record( workbook.summary )
|
259
|
+
assert_equal(target, result, caption)
|
260
|
+
|
261
|
+
###############################################################################
|
262
|
+
#
|
263
|
+
# Test 10. Same as previous + Last author.
|
264
|
+
#
|
265
|
+
|
266
|
+
workbook.set_properties(
|
267
|
+
:title => 'Title',
|
268
|
+
:subject => 'Subject',
|
269
|
+
:author => 'Author',
|
270
|
+
:keywords => 'Keywords',
|
271
|
+
:comments => 'Comments',
|
272
|
+
:last_author => 'Username',
|
273
|
+
:created => nil
|
274
|
+
)
|
275
|
+
|
276
|
+
caption = " \tset_properties('+ Last author')"
|
277
|
+
target = %w(
|
278
|
+
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
279
|
+
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
280
|
+
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
281
|
+
B4 00 00 00 07 00 00 00 01 00 00 00 40 00 00 00
|
282
|
+
02 00 00 00 48 00 00 00 03 00 00 00 58 00 00 00
|
283
|
+
04 00 00 00 68 00 00 00 05 00 00 00 78 00 00 00
|
284
|
+
06 00 00 00 8C 00 00 00 08 00 00 00 A0 00 00 00
|
285
|
+
02 00 00 00 E4 04 00 00 1E 00 00 00 06 00 00 00
|
286
|
+
54 69 74 6C 65 00 00 00 1E 00 00 00 08 00 00 00
|
287
|
+
53 75 62 6A 65 63 74 00 1E 00 00 00 07 00 00 00
|
288
|
+
41 75 74 68 6F 72 00 00 1E 00 00 00 09 00 00 00
|
289
|
+
4B 65 79 77 6F 72 64 73 00 00 00 00 1E 00 00 00
|
290
|
+
09 00 00 00 43 6F 6D 6D 65 6E 74 73 00 00 00 00
|
291
|
+
1E 00 00 00 09 00 00 00 55 73 65 72 6E 61 6D 65
|
292
|
+
00 00 00 00
|
293
|
+
).join(' ')
|
294
|
+
|
295
|
+
result = unpack_record( workbook.summary )
|
296
|
+
assert_equal(target, result, caption)
|
297
|
+
|
298
|
+
###############################################################################
|
299
|
+
#
|
300
|
+
# Test 11. Same as previous + Creation date.
|
301
|
+
#
|
302
|
+
|
303
|
+
# Aug 19 23:20:13 2008
|
304
|
+
# $sec,$min,$hour,$mday,$mon,$year
|
305
|
+
# We normalise the time using timegm() so that the tests don't fail due to
|
306
|
+
# different timezones.
|
307
|
+
|
308
|
+
filetime = Time.gm(2008,8,19,23,20,13)
|
309
|
+
workbook.set_properties(
|
310
|
+
:title => 'Title',
|
311
|
+
:subject => 'Subject',
|
312
|
+
:author => 'Author',
|
313
|
+
:keywords => 'Keywords',
|
314
|
+
:comments => 'Comments',
|
315
|
+
:last_author => 'Username',
|
316
|
+
:created => filetime
|
317
|
+
)
|
318
|
+
|
319
|
+
caption = " \tset_properties('+ Creation date')"
|
320
|
+
target = %w(
|
321
|
+
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
322
|
+
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
323
|
+
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
324
|
+
C8 00 00 00 08 00 00 00 01 00 00 00 48 00 00 00
|
325
|
+
02 00 00 00 50 00 00 00 03 00 00 00 60 00 00 00
|
326
|
+
04 00 00 00 70 00 00 00 05 00 00 00 80 00 00 00
|
327
|
+
06 00 00 00 94 00 00 00 08 00 00 00 A8 00 00 00
|
328
|
+
0C 00 00 00 BC 00 00 00 02 00 00 00 E4 04 00 00
|
329
|
+
1E 00 00 00 06 00 00 00 54 69 74 6C 65 00 00 00
|
330
|
+
1E 00 00 00 08 00 00 00 53 75 62 6A 65 63 74 00
|
331
|
+
1E 00 00 00 07 00 00 00 41 75 74 68 6F 72 00 00
|
332
|
+
1E 00 00 00 09 00 00 00 4B 65 79 77 6F 72 64 73
|
333
|
+
00 00 00 00 1E 00 00 00 09 00 00 00 43 6F 6D 6D
|
334
|
+
65 6E 74 73 00 00 00 00 1E 00 00 00 09 00 00 00
|
335
|
+
55 73 65 72 6E 61 6D 65 00 00 00 00 40 00 00 00
|
336
|
+
80 74 89 21 52 02 C9 01
|
337
|
+
).join(' ')
|
338
|
+
|
339
|
+
result = unpack_record( workbook.summary )
|
340
|
+
assert_equal(target, result, caption)
|
341
|
+
|
342
|
+
###############################################################################
|
343
|
+
#
|
344
|
+
# Test 12. Same as previous. Date set at the workbook level.
|
345
|
+
#
|
346
|
+
|
347
|
+
# Wed Aug 20 00:20:13 2008
|
348
|
+
# $sec,$min,$hour,$mday,$mon,$year
|
349
|
+
# We normalise the time using timegm() so that the tests don't fail due to
|
350
|
+
# different timezones.
|
351
|
+
workbook.localtime = Time.gm(2008,8,19,23,20,13)
|
352
|
+
|
353
|
+
workbook.set_properties(
|
354
|
+
:title => 'Title',
|
355
|
+
:subject => 'Subject',
|
356
|
+
:author => 'Author',
|
357
|
+
:keywords => 'Keywords',
|
358
|
+
:comments => 'Comments',
|
359
|
+
:last_author => 'Username'
|
360
|
+
)
|
361
|
+
|
362
|
+
caption = " \tset_properties('+ Creation date')"
|
363
|
+
target = %w(
|
364
|
+
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
365
|
+
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
366
|
+
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
367
|
+
C8 00 00 00 08 00 00 00 01 00 00 00 48 00 00 00
|
368
|
+
02 00 00 00 50 00 00 00 03 00 00 00 60 00 00 00
|
369
|
+
04 00 00 00 70 00 00 00 05 00 00 00 80 00 00 00
|
370
|
+
06 00 00 00 94 00 00 00 08 00 00 00 A8 00 00 00
|
371
|
+
0C 00 00 00 BC 00 00 00 02 00 00 00 E4 04 00 00
|
372
|
+
1E 00 00 00 06 00 00 00 54 69 74 6C 65 00 00 00
|
373
|
+
1E 00 00 00 08 00 00 00 53 75 62 6A 65 63 74 00
|
374
|
+
1E 00 00 00 07 00 00 00 41 75 74 68 6F 72 00 00
|
375
|
+
1E 00 00 00 09 00 00 00 4B 65 79 77 6F 72 64 73
|
376
|
+
00 00 00 00 1E 00 00 00 09 00 00 00 43 6F 6D 6D
|
377
|
+
65 6E 74 73 00 00 00 00 1E 00 00 00 09 00 00 00
|
378
|
+
55 73 65 72 6E 61 6D 65 00 00 00 00 40 00 00 00
|
379
|
+
80 74 89 21 52 02 C9 01
|
380
|
+
).join(' ')
|
381
|
+
|
382
|
+
result = unpack_record( workbook.summary )
|
383
|
+
assert_equal(target, result, caption)
|
384
|
+
|
385
|
+
###############################################################################
|
386
|
+
#
|
387
|
+
# Test 14. UTF-8 string used.
|
388
|
+
#
|
389
|
+
|
390
|
+
workbook.set_properties(
|
391
|
+
:title => 'Title' + smiley,
|
392
|
+
:created => nil
|
393
|
+
)
|
394
|
+
|
395
|
+
caption = " \tset_properties(utf8)"
|
396
|
+
target = %w(
|
397
|
+
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
398
|
+
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
399
|
+
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
400
|
+
34 00 00 00 02 00 00 00 01 00 00 00 18 00 00 00
|
401
|
+
02 00 00 00 20 00 00 00 02 00 00 00 E9 FD 00 00
|
402
|
+
1E 00 00 00 09 00 00 00 54 69 74 6C 65 E2 98 BA
|
403
|
+
00 00 00 00
|
404
|
+
).join(' ')
|
405
|
+
|
406
|
+
result = unpack_record( workbook.summary )
|
407
|
+
assert_equal(target, result, caption)
|
408
|
+
|
409
|
+
end
|
410
|
+
|
411
|
+
###############################################################################
|
412
|
+
#
|
413
|
+
# Unpack the binary data into a format suitable for printing in tests.
|
414
|
+
#
|
415
|
+
def unpack_record(data)
|
416
|
+
data.unpack('C*').map! {|c| sprintf("%02X", c) }.join(' ')
|
417
|
+
end
|
418
|
+
|
419
|
+
end
|
data/test/ts_all.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
$LOAD_PATH.unshift(Dir.pwd)
|
2
|
+
$LOAD_PATH.unshift(Dir.pwd + "/test")
|
3
|
+
|
4
|
+
require "tc_biff"
|
5
|
+
require "tc_ole"
|
6
|
+
require "tc_workbook"
|
7
|
+
require "tc_worksheet"
|
8
|
+
require "tc_format"
|
9
|
+
require "tc_formula"
|
10
|
+
require 'tc_chart'
|
11
|
+
require "test_00_IEEE_double"
|
12
|
+
require 'test_01_add_worksheet'
|
13
|
+
require 'test_02_merge_formats'
|
14
|
+
require 'test_04_dimensions'
|
15
|
+
require 'test_05_rows'
|
16
|
+
require 'test_06_extsst'
|
17
|
+
require 'test_11_date_time'
|
18
|
+
require 'test_12_date_only'
|
19
|
+
require 'test_13_date_seconds'
|
20
|
+
require 'test_21_escher'
|
21
|
+
require 'test_22_mso_drawing_group'
|
22
|
+
require 'test_23_note'
|
23
|
+
require 'test_24_txo'
|
24
|
+
require 'test_26_autofilter'
|
25
|
+
require 'test_27_autofilter'
|
26
|
+
require 'test_28_autofilter'
|
27
|
+
require 'test_29_process_jpg'
|
28
|
+
require 'test_30_validation_dval'
|
29
|
+
require 'test_31_validation_dv_strings'
|
30
|
+
require 'test_32_validation_dv_formula'
|
31
|
+
require 'test_40_property_types'
|
32
|
+
require 'test_41_properties'
|
33
|
+
require 'test_42_set_properties'
|
34
|
+
require 'tc_example_match'
|
metadata
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: writeexcel
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Hideo Nakamura
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-03-25 00:00:00 +09:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: ruby-ole
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.2.8.2
|
24
|
+
version:
|
25
|
+
description:
|
26
|
+
email: cxn03651@msj.biglobe.ne.jp
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files: []
|
32
|
+
|
33
|
+
files:
|
34
|
+
- examples/merge5.rb
|
35
|
+
- examples/header.rb
|
36
|
+
- examples/regions.rb
|
37
|
+
- examples/merge2.rb
|
38
|
+
- examples/formats.rb
|
39
|
+
- examples/stocks.rb
|
40
|
+
- examples/images.rb
|
41
|
+
- examples/hidden.rb
|
42
|
+
- examples/date_time.rb
|
43
|
+
- examples/a_simple.rb
|
44
|
+
- examples/merge3.rb
|
45
|
+
- examples/merge1.rb
|
46
|
+
- examples/autofilters.rb
|
47
|
+
- examples/demo.rb
|
48
|
+
- examples/hyperlink.rb
|
49
|
+
- examples/diag_border.rb
|
50
|
+
- examples/protection.rb
|
51
|
+
- examples/copyformat.rb
|
52
|
+
- examples/republic.png
|
53
|
+
- examples/stats.rb
|
54
|
+
- examples/tab_colors.rb
|
55
|
+
- examples/merge4.rb
|
56
|
+
- examples/data_validate.rb
|
57
|
+
- examples/repeat.rb
|
58
|
+
- lib/writeexcel.rb
|
59
|
+
- lib/writeexcel/olewriter.rb
|
60
|
+
- lib/writeexcel/properties.rb
|
61
|
+
- lib/writeexcel/chart.rb
|
62
|
+
- lib/writeexcel/formula.rb
|
63
|
+
- lib/writeexcel/format.rb
|
64
|
+
- lib/writeexcel/biffwriter.rb
|
65
|
+
- lib/writeexcel/workbook.rb
|
66
|
+
- lib/writeexcel/worksheet.rb
|
67
|
+
- lib/writeexcel/excelformulaparser.rb
|
68
|
+
- README
|
69
|
+
- test/tc_all.rb
|
70
|
+
- test/tc_chart.rb
|
71
|
+
- test/tc_ole.rb
|
72
|
+
- test/test_40_property_types.rb
|
73
|
+
- test/tc_formula.rb
|
74
|
+
- test/test_00_IEEE_double.rb
|
75
|
+
- test/test_32_validation_dv_formula.rb
|
76
|
+
- test/test_11_date_time.rb
|
77
|
+
- test/test_29_process_jpg.rb
|
78
|
+
- test/ts_all.rb
|
79
|
+
- test/test_24_txo.rb
|
80
|
+
- test/tc_worksheet.rb
|
81
|
+
- test/test_22_mso_drawing_group.rb
|
82
|
+
- test/perl_output
|
83
|
+
- test/test_41_properties.rb
|
84
|
+
- test/test_27_autofilter.rb
|
85
|
+
- test/tc_biff.rb
|
86
|
+
- test/test_26_autofilter.rb
|
87
|
+
- test/test_12_date_only.rb
|
88
|
+
- test/test_23_note.rb
|
89
|
+
- test/test_30_validation_dval.rb
|
90
|
+
- test/tc_format.rb
|
91
|
+
- test/test_31_validation_dv_strings.rb
|
92
|
+
- test/test_28_autofilter.rb
|
93
|
+
- test/test_01_add_worksheet.rb
|
94
|
+
- test/test_04_dimensions.rb
|
95
|
+
- test/republic.png
|
96
|
+
- test/test_42_set_properties.rb
|
97
|
+
- test/test_13_date_seconds.rb
|
98
|
+
- test/tc_example_match.rb
|
99
|
+
- test/test_02_merge_formats.rb
|
100
|
+
- test/tc_workbook.rb
|
101
|
+
- test/test_05_rows.rb
|
102
|
+
- test/test_06_extsst.rb
|
103
|
+
- test/test_21_escher.rb
|
104
|
+
- test/perl_output/ws_store_colinfo
|
105
|
+
- test/perl_output/ws_store_filtermode
|
106
|
+
- test/perl_output/headers.xls
|
107
|
+
- test/perl_output/stats.xls
|
108
|
+
- test/perl_output/demo.xls
|
109
|
+
- test/perl_output/file_font_key
|
110
|
+
- test/perl_output/hyperlink.xls
|
111
|
+
- test/perl_output/a_simple.xls
|
112
|
+
- test/perl_output/f_font_key
|
113
|
+
- test/perl_output/f_font_biff
|
114
|
+
- test/perl_output/merge5.xls
|
115
|
+
- test/perl_output/ws_store_filtermode_on
|
116
|
+
- test/perl_output/regions.xls
|
117
|
+
- test/perl_output/hidden.xls
|
118
|
+
- test/perl_output/ws_store_selection
|
119
|
+
- test/perl_output/images.xls
|
120
|
+
- test/perl_output/unicode_cyrillic.xls
|
121
|
+
- test/perl_output/workbook2.xls
|
122
|
+
- test/perl_output/merge1.xls
|
123
|
+
- test/perl_output/ws_store_filtermode_off
|
124
|
+
- test/perl_output/data_validate.xls
|
125
|
+
- test/perl_output/merge4.xls
|
126
|
+
- test/perl_output/date_time.xls
|
127
|
+
- test/perl_output/ws_store_dimensions
|
128
|
+
- test/perl_output/ole_write_header
|
129
|
+
- test/perl_output/biff_add_continue_testdata
|
130
|
+
- test/perl_output/ws_colinfo
|
131
|
+
- test/perl_output/ws_store_window2
|
132
|
+
- test/perl_output/merge3.xls
|
133
|
+
- test/perl_output/file_xf_biff
|
134
|
+
- test/perl_output/workbook1.xls
|
135
|
+
- test/perl_output/diag_border.xls
|
136
|
+
- test/perl_output/README
|
137
|
+
- test/perl_output/file_font_biff
|
138
|
+
- test/perl_output/merge2.xls
|
139
|
+
- test/perl_output/protection.xls
|
140
|
+
- test/perl_output/tab_colors.xls
|
141
|
+
- test/perl_output/stocks.xls
|
142
|
+
- test/perl_output/f_xf_biff
|
143
|
+
has_rdoc: false
|
144
|
+
homepage:
|
145
|
+
post_install_message:
|
146
|
+
rdoc_options: []
|
147
|
+
|
148
|
+
require_paths:
|
149
|
+
- lib
|
150
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: "1.8"
|
155
|
+
version:
|
156
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: "0"
|
161
|
+
version:
|
162
|
+
requirements: []
|
163
|
+
|
164
|
+
rubyforge_project:
|
165
|
+
rubygems_version: 1.3.1
|
166
|
+
signing_key:
|
167
|
+
specification_version: 2
|
168
|
+
summary: Write to a cross-platform Excel binary file.
|
169
|
+
test_files:
|
170
|
+
- test/ts_all.rb
|