writeexcel 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitattributes +1 -1
- data/.gitignore +24 -24
- data/README.rdoc +34 -55
- data/VERSION +1 -1
- data/charts/chartex.rb +316 -316
- data/charts/demo1.rb +46 -46
- data/charts/demo2.rb +65 -65
- data/charts/demo3.rb +117 -117
- data/charts/demo4.rb +119 -119
- data/charts/demo5.rb +48 -48
- data/examples/a_simple.rb +43 -43
- data/examples/autofilter.rb +265 -265
- data/examples/bigfile.rb +30 -30
- data/examples/chart_area.rb +121 -121
- data/examples/chart_bar.rb +120 -120
- data/examples/chart_column.rb +120 -120
- data/examples/chart_line.rb +120 -120
- data/examples/chart_pie.rb +108 -108
- data/examples/chart_scatter.rb +121 -121
- data/examples/chart_stock.rb +148 -148
- data/examples/chess.rb +142 -142
- data/examples/colors.rb +129 -129
- data/examples/comments1.rb +27 -27
- data/examples/comments2.rb +352 -352
- data/examples/copyformat.rb +52 -52
- data/examples/data_validate.rb +279 -279
- data/examples/date_time.rb +87 -87
- data/examples/defined_name.rb +32 -32
- data/examples/demo.rb +124 -124
- data/examples/diag_border.rb +36 -36
- data/examples/formats.rb +490 -490
- data/examples/formula_result.rb +30 -30
- data/examples/header.rb +137 -137
- data/examples/hide_sheet.rb +29 -29
- data/examples/hyperlink.rb +43 -43
- data/examples/images.rb +63 -63
- data/examples/indent.rb +31 -31
- data/examples/merge1.rb +40 -40
- data/examples/merge2.rb +45 -45
- data/examples/merge3.rb +66 -66
- data/examples/merge4.rb +83 -83
- data/examples/merge5.rb +80 -80
- data/examples/merge6.rb +67 -67
- data/examples/outline.rb +255 -255
- data/examples/outline_collapsed.rb +209 -209
- data/examples/panes.rb +113 -113
- data/examples/properties.rb +34 -34
- data/examples/properties_jp.rb +33 -33
- data/examples/protection.rb +47 -47
- data/examples/regions.rb +53 -53
- data/examples/repeat.rb +43 -43
- data/examples/right_to_left.rb +27 -27
- data/examples/row_wrap.rb +53 -53
- data/examples/stats.rb +74 -74
- data/examples/stocks.rb +81 -81
- data/examples/tab_colors.rb +31 -31
- data/examples/utf8.rb +15 -15
- data/examples/write_arrays.rb +83 -83
- data/lib/writeexcel/biffwriter.rb +232 -232
- data/lib/writeexcel/caller_info.rb +12 -12
- data/lib/writeexcel/chart.rb +2190 -2177
- data/lib/writeexcel/charts/area.rb +154 -154
- data/lib/writeexcel/charts/bar.rb +177 -177
- data/lib/writeexcel/charts/column.rb +156 -156
- data/lib/writeexcel/charts/external.rb +66 -66
- data/lib/writeexcel/charts/line.rb +154 -154
- data/lib/writeexcel/charts/pie.rb +169 -169
- data/lib/writeexcel/charts/scatter.rb +192 -192
- data/lib/writeexcel/charts/stock.rb +213 -213
- data/lib/writeexcel/colors.rb +64 -64
- data/lib/writeexcel/compatibility.rb +0 -255
- data/lib/writeexcel/debug_info.rb +37 -33
- data/lib/writeexcel/excelformulaparser.rb +587 -587
- data/lib/writeexcel/format.rb +13 -4
- data/lib/writeexcel/formula.rb +26 -9
- data/lib/writeexcel/helper.rb +68 -64
- data/lib/writeexcel/olewriter.rb +311 -311
- data/lib/writeexcel/properties.rb +242 -240
- data/lib/writeexcel/storage_lite.rb +984 -978
- data/lib/writeexcel/workbook.rb +3210 -3192
- data/lib/writeexcel/worksheet.rb +143 -51
- data/lib/writeexcel/write_file.rb +44 -40
- data/lib/writeexcel.rb +1159 -1159
- data/test/helper.rb +31 -28
- data/test/perl_output/README +31 -31
- data/test/test_00_IEEE_double.rb +13 -13
- data/test/test_01_add_worksheet.rb +10 -10
- data/test/test_02_merge_formats.rb +53 -53
- data/test/test_04_dimensions.rb +392 -392
- data/test/test_05_rows.rb +179 -179
- data/test/test_06_extsst.rb +77 -77
- data/test/test_11_date_time.rb +479 -479
- data/test/test_12_date_only.rb +501 -501
- data/test/test_13_date_seconds.rb +481 -481
- data/test/test_21_escher.rb +637 -637
- data/test/test_22_mso_drawing_group.rb +745 -745
- data/test/test_23_note.rb +73 -73
- data/test/test_24_txo.rb +75 -75
- data/test/test_25_position_object.rb +84 -84
- data/test/test_26_autofilter.rb +314 -314
- data/test/test_27_autofilter.rb +131 -131
- data/test/test_28_autofilter.rb +161 -161
- data/test/test_29_process_jpg.rb +683 -683
- data/test/test_30_validation_dval.rb +77 -77
- data/test/test_31_validation_dv_strings.rb +126 -126
- data/test/test_32_validation_dv_formula.rb +206 -206
- data/test/test_40_property_types.rb +188 -188
- data/test/test_41_properties.rb +235 -235
- data/test/test_42_set_properties.rb +437 -437
- data/test/test_50_name_stored.rb +299 -299
- data/test/test_51_name_print_area.rb +357 -357
- data/test/test_52_name_print_titles.rb +454 -454
- data/test/test_53_autofilter.rb +203 -203
- data/test/test_60_chart_generic.rb +578 -578
- data/test/test_61_chart_subclasses.rb +95 -95
- data/test/test_62_chart_formats.rb +272 -272
- data/test/test_63_chart_area_formats.rb +649 -649
- data/test/test_biff.rb +75 -75
- data/test/test_compatibility.rb +12 -627
- data/test/test_example_match.rb +3144 -3144
- data/test/test_formula.rb +61 -61
- data/test/test_ole.rb +106 -106
- data/test/test_storage_lite.rb +125 -125
- data/test/test_workbook.rb +139 -139
- data/test/test_worksheet.rb +110 -110
- data/utils/add_magic_comment.rb +80 -80
- data/writeexcel.gemspec +4 -6
- data/writeexcel.rdoc +58 -15
- metadata +9 -6
- data/test/test_new_encoding.rb +0 -205
data/test/test_04_dimensions.rb
CHANGED
@@ -1,392 +1,392 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
###############################################################################
|
3
|
-
#
|
4
|
-
# A test for WriteExcel.
|
5
|
-
#
|
6
|
-
# Check that the Excel DIMENSIONS record is written correctly.
|
7
|
-
#
|
8
|
-
# reverse('©'), October 2007, 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
|
-
require 'helper'
|
15
|
-
require 'stringio'
|
16
|
-
|
17
|
-
class TC_dimensions < Test::Unit::TestCase
|
18
|
-
|
19
|
-
def setup
|
20
|
-
@workbook = WriteExcel.new(StringIO.new)
|
21
|
-
@worksheet = @workbook.add_worksheet
|
22
|
-
@format = @workbook.add_format
|
23
|
-
@dims = ['row_min', 'row_max', 'col_min', 'col_max']
|
24
|
-
@smiley = [0x263a].pack('n')
|
25
|
-
end
|
26
|
-
|
27
|
-
def teardown
|
28
|
-
@workbook.close
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_no_worksheet_cell_data
|
32
|
-
data = @worksheet.store_dimensions
|
33
|
-
|
34
|
-
vals = data.unpack('x4 VVvv')
|
35
|
-
alist = @dims.zip(vals)
|
36
|
-
results = Hash[*alist.flatten]
|
37
|
-
|
38
|
-
alist = @dims.zip([0, 0, 0, 0])
|
39
|
-
expected = Hash[*alist.flatten]
|
40
|
-
|
41
|
-
assert_equal(expected, results)
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_data_in_cell_0_0
|
45
|
-
@worksheet.write(0, 0, 'Test')
|
46
|
-
data = @worksheet.store_dimensions
|
47
|
-
|
48
|
-
vals = data.unpack('x4 VVvv')
|
49
|
-
alist = @dims.zip(vals)
|
50
|
-
results = Hash[*alist.flatten]
|
51
|
-
|
52
|
-
alist = @dims.zip([0, 1, 0, 1])
|
53
|
-
expected = Hash[*alist.flatten]
|
54
|
-
|
55
|
-
assert_equal(expected, results)
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_data_in_cell_0_255
|
59
|
-
@worksheet.write(0, 255, 'Test')
|
60
|
-
data = @worksheet.store_dimensions
|
61
|
-
|
62
|
-
vals = data.unpack('x4 VVvv')
|
63
|
-
alist = @dims.zip(vals)
|
64
|
-
results = Hash[*alist.flatten]
|
65
|
-
|
66
|
-
alist = @dims.zip([0, 1, 255, 256])
|
67
|
-
expected = Hash[*alist.flatten]
|
68
|
-
|
69
|
-
assert_equal(expected, results)
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_data_in_cell_65535_0
|
73
|
-
@worksheet.write(65535, 0, 'Test')
|
74
|
-
data = @worksheet.store_dimensions
|
75
|
-
|
76
|
-
vals = data.unpack('x4 VVvv')
|
77
|
-
alist = @dims.zip(vals)
|
78
|
-
results = Hash[*alist.flatten]
|
79
|
-
|
80
|
-
alist = @dims.zip([65535, 65536, 0, 1])
|
81
|
-
expected = Hash[*alist.flatten]
|
82
|
-
|
83
|
-
assert_equal(expected, results)
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_data_in_cell_65535_255
|
87
|
-
@worksheet.write(65535, 255, 'Test')
|
88
|
-
data = @worksheet.store_dimensions
|
89
|
-
|
90
|
-
vals = data.unpack('x4 VVvv')
|
91
|
-
alist = @dims.zip(vals)
|
92
|
-
results = Hash[*alist.flatten]
|
93
|
-
|
94
|
-
alist = @dims.zip([65535, 65536, 255, 256])
|
95
|
-
expected = Hash[*alist.flatten]
|
96
|
-
|
97
|
-
assert_equal(expected, results)
|
98
|
-
end
|
99
|
-
|
100
|
-
def test_set_row_for_row_4
|
101
|
-
@worksheet.set_row(4, 20)
|
102
|
-
data = @worksheet.store_dimensions
|
103
|
-
|
104
|
-
vals = data.unpack('x4 VVvv')
|
105
|
-
alist = @dims.zip(vals)
|
106
|
-
results = Hash[*alist.flatten]
|
107
|
-
|
108
|
-
alist = @dims.zip([4, 5, 0, 0])
|
109
|
-
expected = Hash[*alist.flatten]
|
110
|
-
|
111
|
-
assert_equal(expected, results)
|
112
|
-
end
|
113
|
-
|
114
|
-
def test_set_row_for_row_4_to_6
|
115
|
-
@worksheet.set_row(4, 20)
|
116
|
-
@worksheet.set_row(5, 20)
|
117
|
-
@worksheet.set_row(6, 20)
|
118
|
-
data = @worksheet.store_dimensions
|
119
|
-
|
120
|
-
vals = data.unpack('x4 VVvv')
|
121
|
-
alist = @dims.zip(vals)
|
122
|
-
results = Hash[*alist.flatten]
|
123
|
-
|
124
|
-
alist = @dims.zip([4, 7, 0, 0])
|
125
|
-
expected = Hash[*alist.flatten]
|
126
|
-
|
127
|
-
assert_equal(expected, results)
|
128
|
-
end
|
129
|
-
|
130
|
-
def test_set_column_for_row_4
|
131
|
-
@worksheet.set_column(4, 4, 20)
|
132
|
-
data = @worksheet.store_dimensions
|
133
|
-
|
134
|
-
vals = data.unpack('x4 VVvv')
|
135
|
-
alist = @dims.zip(vals)
|
136
|
-
results = Hash[*alist.flatten]
|
137
|
-
|
138
|
-
alist = @dims.zip([0, 0, 0, 0])
|
139
|
-
expected = Hash[*alist.flatten]
|
140
|
-
|
141
|
-
assert_equal(expected, results)
|
142
|
-
end
|
143
|
-
|
144
|
-
def test_data_in_cell_0_0_and_set_row_for_row_4
|
145
|
-
@worksheet.write(0, 0, 'Test')
|
146
|
-
@worksheet.set_row(4, 20)
|
147
|
-
data = @worksheet.store_dimensions
|
148
|
-
|
149
|
-
vals = data.unpack('x4 VVvv')
|
150
|
-
alist = @dims.zip(vals)
|
151
|
-
results = Hash[*alist.flatten]
|
152
|
-
|
153
|
-
alist = @dims.zip([0, 5, 0, 1])
|
154
|
-
expected = Hash[*alist.flatten]
|
155
|
-
|
156
|
-
assert_equal(expected, results)
|
157
|
-
end
|
158
|
-
|
159
|
-
def test_data_in_cell_0_0_and_set_row_for_row_4_reverse_order
|
160
|
-
@worksheet.set_row(4, 20)
|
161
|
-
@worksheet.write(0, 0, 'Test')
|
162
|
-
data = @worksheet.store_dimensions
|
163
|
-
|
164
|
-
vals = data.unpack('x4 VVvv')
|
165
|
-
alist = @dims.zip(vals)
|
166
|
-
results = Hash[*alist.flatten]
|
167
|
-
|
168
|
-
alist = @dims.zip([0, 5, 0, 1])
|
169
|
-
expected = Hash[*alist.flatten]
|
170
|
-
|
171
|
-
assert_equal(expected, results)
|
172
|
-
end
|
173
|
-
|
174
|
-
def test_data_in_cell_5_3_and_set_row_for_row_4
|
175
|
-
@worksheet.write(5, 3, 'Test')
|
176
|
-
@worksheet.set_row(4, 20)
|
177
|
-
data = @worksheet.store_dimensions
|
178
|
-
|
179
|
-
vals = data.unpack('x4 VVvv')
|
180
|
-
alist = @dims.zip(vals)
|
181
|
-
results = Hash[*alist.flatten]
|
182
|
-
|
183
|
-
alist = @dims.zip([4, 6, 3, 4])
|
184
|
-
expected = Hash[*alist.flatten]
|
185
|
-
|
186
|
-
assert_equal(expected, results)
|
187
|
-
end
|
188
|
-
|
189
|
-
def test_comment_in_cell_5_3
|
190
|
-
@worksheet.write_comment(5, 3, 'Test')
|
191
|
-
data = @worksheet.store_dimensions
|
192
|
-
|
193
|
-
vals = data.unpack('x4 VVvv')
|
194
|
-
alist = @dims.zip(vals)
|
195
|
-
results = Hash[*alist.flatten]
|
196
|
-
|
197
|
-
alist = @dims.zip([5, 6, 3, 4])
|
198
|
-
expected = Hash[*alist.flatten]
|
199
|
-
|
200
|
-
assert_equal(expected, results)
|
201
|
-
end
|
202
|
-
|
203
|
-
def test_nil_value_for_row
|
204
|
-
error = @worksheet.write_string(nil, 1, 'Test')
|
205
|
-
data = @worksheet.store_dimensions
|
206
|
-
|
207
|
-
vals = data.unpack('x4 VVvv')
|
208
|
-
alist = @dims.zip(vals)
|
209
|
-
results = Hash[*alist.flatten]
|
210
|
-
|
211
|
-
alist = @dims.zip([0, 0, 0, 0])
|
212
|
-
expected = Hash[*alist.flatten]
|
213
|
-
|
214
|
-
assert_equal(expected, results)
|
215
|
-
assert_equal(-2, error)
|
216
|
-
end
|
217
|
-
|
218
|
-
def test_data_in_cell_5_3_and_10_1
|
219
|
-
@worksheet.write( 5, 3, 'Test')
|
220
|
-
@worksheet.write(10, 1, 'Test')
|
221
|
-
data = @worksheet.store_dimensions
|
222
|
-
|
223
|
-
vals = data.unpack('x4 VVvv')
|
224
|
-
alist = @dims.zip(vals)
|
225
|
-
results = Hash[*alist.flatten]
|
226
|
-
|
227
|
-
alist = @dims.zip([5, 11, 1, 4])
|
228
|
-
expected = Hash[*alist.flatten]
|
229
|
-
|
230
|
-
assert_equal(expected, results)
|
231
|
-
end
|
232
|
-
|
233
|
-
def test_data_in_cell_5_3_and_10_5
|
234
|
-
@worksheet.write( 5, 3, 'Test')
|
235
|
-
@worksheet.write(10, 5, 'Test')
|
236
|
-
data = @worksheet.store_dimensions
|
237
|
-
|
238
|
-
vals = data.unpack('x4 VVvv')
|
239
|
-
alist = @dims.zip(vals)
|
240
|
-
results = Hash[*alist.flatten]
|
241
|
-
|
242
|
-
alist = @dims.zip([5, 11, 3, 6])
|
243
|
-
expected = Hash[*alist.flatten]
|
244
|
-
|
245
|
-
assert_equal(expected, results)
|
246
|
-
end
|
247
|
-
|
248
|
-
def test_write_string
|
249
|
-
@worksheet.write_string(5, 3, 'Test')
|
250
|
-
data = @worksheet.store_dimensions
|
251
|
-
|
252
|
-
vals = data.unpack('x4 VVvv')
|
253
|
-
alist = @dims.zip(vals)
|
254
|
-
results = Hash[*alist.flatten]
|
255
|
-
|
256
|
-
alist = @dims.zip([5, 6, 3, 4])
|
257
|
-
expected = Hash[*alist.flatten]
|
258
|
-
|
259
|
-
assert_equal(expected, results)
|
260
|
-
end
|
261
|
-
|
262
|
-
def test_write_number
|
263
|
-
@worksheet.write_number(5, 3, 5)
|
264
|
-
data = @worksheet.store_dimensions
|
265
|
-
|
266
|
-
vals = data.unpack('x4 VVvv')
|
267
|
-
alist = @dims.zip(vals)
|
268
|
-
results = Hash[*alist.flatten]
|
269
|
-
|
270
|
-
alist = @dims.zip([5, 6, 3, 4])
|
271
|
-
expected = Hash[*alist.flatten]
|
272
|
-
|
273
|
-
assert_equal(expected, results)
|
274
|
-
end
|
275
|
-
|
276
|
-
def test_write_url
|
277
|
-
@worksheet.write_url(5, 3, 'http://www.ruby.com')
|
278
|
-
data = @worksheet.store_dimensions
|
279
|
-
|
280
|
-
vals = data.unpack('x4 VVvv')
|
281
|
-
alist = @dims.zip(vals)
|
282
|
-
results = Hash[*alist.flatten]
|
283
|
-
|
284
|
-
alist = @dims.zip([5, 6, 3, 4])
|
285
|
-
expected = Hash[*alist.flatten]
|
286
|
-
|
287
|
-
assert_equal(expected, results)
|
288
|
-
end
|
289
|
-
|
290
|
-
def test_write_formula
|
291
|
-
@worksheet.write_formula(5, 3, ' 1 + 2')
|
292
|
-
data = @worksheet.store_dimensions
|
293
|
-
|
294
|
-
vals = data.unpack('x4 VVvv')
|
295
|
-
alist = @dims.zip(vals)
|
296
|
-
results = Hash[*alist.flatten]
|
297
|
-
|
298
|
-
alist = @dims.zip([5, 6, 3, 4])
|
299
|
-
expected = Hash[*alist.flatten]
|
300
|
-
|
301
|
-
assert_equal(expected, results)
|
302
|
-
end
|
303
|
-
|
304
|
-
def test_write_blank
|
305
|
-
@worksheet.write_string(5, 3, @format)
|
306
|
-
data = @worksheet.store_dimensions
|
307
|
-
|
308
|
-
vals = data.unpack('x4 VVvv')
|
309
|
-
alist = @dims.zip(vals)
|
310
|
-
results = Hash[*alist.flatten]
|
311
|
-
|
312
|
-
alist = @dims.zip([5, 6, 3, 4])
|
313
|
-
expected = Hash[*alist.flatten]
|
314
|
-
|
315
|
-
assert_equal(expected, results)
|
316
|
-
end
|
317
|
-
|
318
|
-
def test_write_blank_no_format
|
319
|
-
@worksheet.write_string(5, 3)
|
320
|
-
data = @worksheet.store_dimensions
|
321
|
-
|
322
|
-
vals = data.unpack('x4 VVvv')
|
323
|
-
alist = @dims.zip(vals)
|
324
|
-
results = Hash[*alist.flatten]
|
325
|
-
|
326
|
-
alist = @dims.zip([0, 0, 0, 0])
|
327
|
-
expected = Hash[*alist.flatten]
|
328
|
-
|
329
|
-
assert_equal(expected, results)
|
330
|
-
end
|
331
|
-
|
332
|
-
def test_write_utf16be_string
|
333
|
-
@worksheet.write_utf16be_string(5, 3, @smiley)
|
334
|
-
data = @worksheet.store_dimensions
|
335
|
-
|
336
|
-
vals = data.unpack('x4 VVvv')
|
337
|
-
alist = @dims.zip(vals)
|
338
|
-
results = Hash[*alist.flatten]
|
339
|
-
|
340
|
-
alist = @dims.zip([5, 6, 3, 4])
|
341
|
-
expected = Hash[*alist.flatten]
|
342
|
-
|
343
|
-
assert_equal(expected, results)
|
344
|
-
end
|
345
|
-
|
346
|
-
def test_write_utf16le_string
|
347
|
-
@worksheet.write_utf16le_string(5, 3, @smiley)
|
348
|
-
data = @worksheet.store_dimensions
|
349
|
-
|
350
|
-
vals = data.unpack('x4 VVvv')
|
351
|
-
alist = @dims.zip(vals)
|
352
|
-
results = Hash[*alist.flatten]
|
353
|
-
|
354
|
-
alist = @dims.zip([5, 6, 3, 4])
|
355
|
-
expected = Hash[*alist.flatten]
|
356
|
-
|
357
|
-
assert_equal(expected, results)
|
358
|
-
end
|
359
|
-
|
360
|
-
def test_repeat_formula
|
361
|
-
formula = @worksheet.store_formula('=A1 * 3 + 50')
|
362
|
-
@worksheet.repeat_formula(5, 3, formula, @format, 'A1', 'A2')
|
363
|
-
|
364
|
-
data = @worksheet.store_dimensions
|
365
|
-
|
366
|
-
vals = data.unpack('x4 VVvv')
|
367
|
-
alist = @dims.zip(vals)
|
368
|
-
results = Hash[*alist.flatten]
|
369
|
-
|
370
|
-
alist = @dims.zip([5, 6, 3, 4])
|
371
|
-
expected = Hash[*alist.flatten]
|
372
|
-
|
373
|
-
assert_equal(expected, results)
|
374
|
-
end
|
375
|
-
|
376
|
-
def test_merge_range
|
377
|
-
formula = @worksheet.store_formula('=A1 * 3 + 50')
|
378
|
-
@worksheet.merge_range('C6:E8', 'Test', @format)
|
379
|
-
|
380
|
-
data = @worksheet.store_dimensions
|
381
|
-
|
382
|
-
vals = data.unpack('x4 VVvv')
|
383
|
-
alist = @dims.zip(vals)
|
384
|
-
results = Hash[*alist.flatten]
|
385
|
-
|
386
|
-
alist = @dims.zip([5, 8, 2, 5])
|
387
|
-
expected = Hash[*alist.flatten]
|
388
|
-
|
389
|
-
assert_equal(expected, results)
|
390
|
-
end
|
391
|
-
|
392
|
-
end
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
###############################################################################
|
3
|
+
#
|
4
|
+
# A test for WriteExcel.
|
5
|
+
#
|
6
|
+
# Check that the Excel DIMENSIONS record is written correctly.
|
7
|
+
#
|
8
|
+
# reverse('©'), October 2007, 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
|
+
require 'helper'
|
15
|
+
require 'stringio'
|
16
|
+
|
17
|
+
class TC_dimensions < Test::Unit::TestCase
|
18
|
+
|
19
|
+
def setup
|
20
|
+
@workbook = WriteExcel.new(StringIO.new)
|
21
|
+
@worksheet = @workbook.add_worksheet
|
22
|
+
@format = @workbook.add_format
|
23
|
+
@dims = ['row_min', 'row_max', 'col_min', 'col_max']
|
24
|
+
@smiley = [0x263a].pack('n')
|
25
|
+
end
|
26
|
+
|
27
|
+
def teardown
|
28
|
+
@workbook.close
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_no_worksheet_cell_data
|
32
|
+
data = @worksheet.store_dimensions
|
33
|
+
|
34
|
+
vals = data.unpack('x4 VVvv')
|
35
|
+
alist = @dims.zip(vals)
|
36
|
+
results = Hash[*alist.flatten]
|
37
|
+
|
38
|
+
alist = @dims.zip([0, 0, 0, 0])
|
39
|
+
expected = Hash[*alist.flatten]
|
40
|
+
|
41
|
+
assert_equal(expected, results)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_data_in_cell_0_0
|
45
|
+
@worksheet.write(0, 0, 'Test')
|
46
|
+
data = @worksheet.store_dimensions
|
47
|
+
|
48
|
+
vals = data.unpack('x4 VVvv')
|
49
|
+
alist = @dims.zip(vals)
|
50
|
+
results = Hash[*alist.flatten]
|
51
|
+
|
52
|
+
alist = @dims.zip([0, 1, 0, 1])
|
53
|
+
expected = Hash[*alist.flatten]
|
54
|
+
|
55
|
+
assert_equal(expected, results)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_data_in_cell_0_255
|
59
|
+
@worksheet.write(0, 255, 'Test')
|
60
|
+
data = @worksheet.store_dimensions
|
61
|
+
|
62
|
+
vals = data.unpack('x4 VVvv')
|
63
|
+
alist = @dims.zip(vals)
|
64
|
+
results = Hash[*alist.flatten]
|
65
|
+
|
66
|
+
alist = @dims.zip([0, 1, 255, 256])
|
67
|
+
expected = Hash[*alist.flatten]
|
68
|
+
|
69
|
+
assert_equal(expected, results)
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_data_in_cell_65535_0
|
73
|
+
@worksheet.write(65535, 0, 'Test')
|
74
|
+
data = @worksheet.store_dimensions
|
75
|
+
|
76
|
+
vals = data.unpack('x4 VVvv')
|
77
|
+
alist = @dims.zip(vals)
|
78
|
+
results = Hash[*alist.flatten]
|
79
|
+
|
80
|
+
alist = @dims.zip([65535, 65536, 0, 1])
|
81
|
+
expected = Hash[*alist.flatten]
|
82
|
+
|
83
|
+
assert_equal(expected, results)
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_data_in_cell_65535_255
|
87
|
+
@worksheet.write(65535, 255, 'Test')
|
88
|
+
data = @worksheet.store_dimensions
|
89
|
+
|
90
|
+
vals = data.unpack('x4 VVvv')
|
91
|
+
alist = @dims.zip(vals)
|
92
|
+
results = Hash[*alist.flatten]
|
93
|
+
|
94
|
+
alist = @dims.zip([65535, 65536, 255, 256])
|
95
|
+
expected = Hash[*alist.flatten]
|
96
|
+
|
97
|
+
assert_equal(expected, results)
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_set_row_for_row_4
|
101
|
+
@worksheet.set_row(4, 20)
|
102
|
+
data = @worksheet.store_dimensions
|
103
|
+
|
104
|
+
vals = data.unpack('x4 VVvv')
|
105
|
+
alist = @dims.zip(vals)
|
106
|
+
results = Hash[*alist.flatten]
|
107
|
+
|
108
|
+
alist = @dims.zip([4, 5, 0, 0])
|
109
|
+
expected = Hash[*alist.flatten]
|
110
|
+
|
111
|
+
assert_equal(expected, results)
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_set_row_for_row_4_to_6
|
115
|
+
@worksheet.set_row(4, 20)
|
116
|
+
@worksheet.set_row(5, 20)
|
117
|
+
@worksheet.set_row(6, 20)
|
118
|
+
data = @worksheet.store_dimensions
|
119
|
+
|
120
|
+
vals = data.unpack('x4 VVvv')
|
121
|
+
alist = @dims.zip(vals)
|
122
|
+
results = Hash[*alist.flatten]
|
123
|
+
|
124
|
+
alist = @dims.zip([4, 7, 0, 0])
|
125
|
+
expected = Hash[*alist.flatten]
|
126
|
+
|
127
|
+
assert_equal(expected, results)
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_set_column_for_row_4
|
131
|
+
@worksheet.set_column(4, 4, 20)
|
132
|
+
data = @worksheet.store_dimensions
|
133
|
+
|
134
|
+
vals = data.unpack('x4 VVvv')
|
135
|
+
alist = @dims.zip(vals)
|
136
|
+
results = Hash[*alist.flatten]
|
137
|
+
|
138
|
+
alist = @dims.zip([0, 0, 0, 0])
|
139
|
+
expected = Hash[*alist.flatten]
|
140
|
+
|
141
|
+
assert_equal(expected, results)
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_data_in_cell_0_0_and_set_row_for_row_4
|
145
|
+
@worksheet.write(0, 0, 'Test')
|
146
|
+
@worksheet.set_row(4, 20)
|
147
|
+
data = @worksheet.store_dimensions
|
148
|
+
|
149
|
+
vals = data.unpack('x4 VVvv')
|
150
|
+
alist = @dims.zip(vals)
|
151
|
+
results = Hash[*alist.flatten]
|
152
|
+
|
153
|
+
alist = @dims.zip([0, 5, 0, 1])
|
154
|
+
expected = Hash[*alist.flatten]
|
155
|
+
|
156
|
+
assert_equal(expected, results)
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_data_in_cell_0_0_and_set_row_for_row_4_reverse_order
|
160
|
+
@worksheet.set_row(4, 20)
|
161
|
+
@worksheet.write(0, 0, 'Test')
|
162
|
+
data = @worksheet.store_dimensions
|
163
|
+
|
164
|
+
vals = data.unpack('x4 VVvv')
|
165
|
+
alist = @dims.zip(vals)
|
166
|
+
results = Hash[*alist.flatten]
|
167
|
+
|
168
|
+
alist = @dims.zip([0, 5, 0, 1])
|
169
|
+
expected = Hash[*alist.flatten]
|
170
|
+
|
171
|
+
assert_equal(expected, results)
|
172
|
+
end
|
173
|
+
|
174
|
+
def test_data_in_cell_5_3_and_set_row_for_row_4
|
175
|
+
@worksheet.write(5, 3, 'Test')
|
176
|
+
@worksheet.set_row(4, 20)
|
177
|
+
data = @worksheet.store_dimensions
|
178
|
+
|
179
|
+
vals = data.unpack('x4 VVvv')
|
180
|
+
alist = @dims.zip(vals)
|
181
|
+
results = Hash[*alist.flatten]
|
182
|
+
|
183
|
+
alist = @dims.zip([4, 6, 3, 4])
|
184
|
+
expected = Hash[*alist.flatten]
|
185
|
+
|
186
|
+
assert_equal(expected, results)
|
187
|
+
end
|
188
|
+
|
189
|
+
def test_comment_in_cell_5_3
|
190
|
+
@worksheet.write_comment(5, 3, 'Test')
|
191
|
+
data = @worksheet.store_dimensions
|
192
|
+
|
193
|
+
vals = data.unpack('x4 VVvv')
|
194
|
+
alist = @dims.zip(vals)
|
195
|
+
results = Hash[*alist.flatten]
|
196
|
+
|
197
|
+
alist = @dims.zip([5, 6, 3, 4])
|
198
|
+
expected = Hash[*alist.flatten]
|
199
|
+
|
200
|
+
assert_equal(expected, results)
|
201
|
+
end
|
202
|
+
|
203
|
+
def test_nil_value_for_row
|
204
|
+
error = @worksheet.write_string(nil, 1, 'Test')
|
205
|
+
data = @worksheet.store_dimensions
|
206
|
+
|
207
|
+
vals = data.unpack('x4 VVvv')
|
208
|
+
alist = @dims.zip(vals)
|
209
|
+
results = Hash[*alist.flatten]
|
210
|
+
|
211
|
+
alist = @dims.zip([0, 0, 0, 0])
|
212
|
+
expected = Hash[*alist.flatten]
|
213
|
+
|
214
|
+
assert_equal(expected, results)
|
215
|
+
assert_equal(-2, error)
|
216
|
+
end
|
217
|
+
|
218
|
+
def test_data_in_cell_5_3_and_10_1
|
219
|
+
@worksheet.write( 5, 3, 'Test')
|
220
|
+
@worksheet.write(10, 1, 'Test')
|
221
|
+
data = @worksheet.store_dimensions
|
222
|
+
|
223
|
+
vals = data.unpack('x4 VVvv')
|
224
|
+
alist = @dims.zip(vals)
|
225
|
+
results = Hash[*alist.flatten]
|
226
|
+
|
227
|
+
alist = @dims.zip([5, 11, 1, 4])
|
228
|
+
expected = Hash[*alist.flatten]
|
229
|
+
|
230
|
+
assert_equal(expected, results)
|
231
|
+
end
|
232
|
+
|
233
|
+
def test_data_in_cell_5_3_and_10_5
|
234
|
+
@worksheet.write( 5, 3, 'Test')
|
235
|
+
@worksheet.write(10, 5, 'Test')
|
236
|
+
data = @worksheet.store_dimensions
|
237
|
+
|
238
|
+
vals = data.unpack('x4 VVvv')
|
239
|
+
alist = @dims.zip(vals)
|
240
|
+
results = Hash[*alist.flatten]
|
241
|
+
|
242
|
+
alist = @dims.zip([5, 11, 3, 6])
|
243
|
+
expected = Hash[*alist.flatten]
|
244
|
+
|
245
|
+
assert_equal(expected, results)
|
246
|
+
end
|
247
|
+
|
248
|
+
def test_write_string
|
249
|
+
@worksheet.write_string(5, 3, 'Test')
|
250
|
+
data = @worksheet.store_dimensions
|
251
|
+
|
252
|
+
vals = data.unpack('x4 VVvv')
|
253
|
+
alist = @dims.zip(vals)
|
254
|
+
results = Hash[*alist.flatten]
|
255
|
+
|
256
|
+
alist = @dims.zip([5, 6, 3, 4])
|
257
|
+
expected = Hash[*alist.flatten]
|
258
|
+
|
259
|
+
assert_equal(expected, results)
|
260
|
+
end
|
261
|
+
|
262
|
+
def test_write_number
|
263
|
+
@worksheet.write_number(5, 3, 5)
|
264
|
+
data = @worksheet.store_dimensions
|
265
|
+
|
266
|
+
vals = data.unpack('x4 VVvv')
|
267
|
+
alist = @dims.zip(vals)
|
268
|
+
results = Hash[*alist.flatten]
|
269
|
+
|
270
|
+
alist = @dims.zip([5, 6, 3, 4])
|
271
|
+
expected = Hash[*alist.flatten]
|
272
|
+
|
273
|
+
assert_equal(expected, results)
|
274
|
+
end
|
275
|
+
|
276
|
+
def test_write_url
|
277
|
+
@worksheet.write_url(5, 3, 'http://www.ruby.com')
|
278
|
+
data = @worksheet.store_dimensions
|
279
|
+
|
280
|
+
vals = data.unpack('x4 VVvv')
|
281
|
+
alist = @dims.zip(vals)
|
282
|
+
results = Hash[*alist.flatten]
|
283
|
+
|
284
|
+
alist = @dims.zip([5, 6, 3, 4])
|
285
|
+
expected = Hash[*alist.flatten]
|
286
|
+
|
287
|
+
assert_equal(expected, results)
|
288
|
+
end
|
289
|
+
|
290
|
+
def test_write_formula
|
291
|
+
@worksheet.write_formula(5, 3, ' 1 + 2')
|
292
|
+
data = @worksheet.store_dimensions
|
293
|
+
|
294
|
+
vals = data.unpack('x4 VVvv')
|
295
|
+
alist = @dims.zip(vals)
|
296
|
+
results = Hash[*alist.flatten]
|
297
|
+
|
298
|
+
alist = @dims.zip([5, 6, 3, 4])
|
299
|
+
expected = Hash[*alist.flatten]
|
300
|
+
|
301
|
+
assert_equal(expected, results)
|
302
|
+
end
|
303
|
+
|
304
|
+
def test_write_blank
|
305
|
+
@worksheet.write_string(5, 3, @format)
|
306
|
+
data = @worksheet.store_dimensions
|
307
|
+
|
308
|
+
vals = data.unpack('x4 VVvv')
|
309
|
+
alist = @dims.zip(vals)
|
310
|
+
results = Hash[*alist.flatten]
|
311
|
+
|
312
|
+
alist = @dims.zip([5, 6, 3, 4])
|
313
|
+
expected = Hash[*alist.flatten]
|
314
|
+
|
315
|
+
assert_equal(expected, results)
|
316
|
+
end
|
317
|
+
|
318
|
+
def test_write_blank_no_format
|
319
|
+
@worksheet.write_string(5, 3)
|
320
|
+
data = @worksheet.store_dimensions
|
321
|
+
|
322
|
+
vals = data.unpack('x4 VVvv')
|
323
|
+
alist = @dims.zip(vals)
|
324
|
+
results = Hash[*alist.flatten]
|
325
|
+
|
326
|
+
alist = @dims.zip([0, 0, 0, 0])
|
327
|
+
expected = Hash[*alist.flatten]
|
328
|
+
|
329
|
+
assert_equal(expected, results)
|
330
|
+
end
|
331
|
+
|
332
|
+
def test_write_utf16be_string
|
333
|
+
@worksheet.write_utf16be_string(5, 3, @smiley)
|
334
|
+
data = @worksheet.store_dimensions
|
335
|
+
|
336
|
+
vals = data.unpack('x4 VVvv')
|
337
|
+
alist = @dims.zip(vals)
|
338
|
+
results = Hash[*alist.flatten]
|
339
|
+
|
340
|
+
alist = @dims.zip([5, 6, 3, 4])
|
341
|
+
expected = Hash[*alist.flatten]
|
342
|
+
|
343
|
+
assert_equal(expected, results)
|
344
|
+
end
|
345
|
+
|
346
|
+
def test_write_utf16le_string
|
347
|
+
@worksheet.write_utf16le_string(5, 3, @smiley)
|
348
|
+
data = @worksheet.store_dimensions
|
349
|
+
|
350
|
+
vals = data.unpack('x4 VVvv')
|
351
|
+
alist = @dims.zip(vals)
|
352
|
+
results = Hash[*alist.flatten]
|
353
|
+
|
354
|
+
alist = @dims.zip([5, 6, 3, 4])
|
355
|
+
expected = Hash[*alist.flatten]
|
356
|
+
|
357
|
+
assert_equal(expected, results)
|
358
|
+
end
|
359
|
+
|
360
|
+
def test_repeat_formula
|
361
|
+
formula = @worksheet.store_formula('=A1 * 3 + 50')
|
362
|
+
@worksheet.repeat_formula(5, 3, formula, @format, 'A1', 'A2')
|
363
|
+
|
364
|
+
data = @worksheet.store_dimensions
|
365
|
+
|
366
|
+
vals = data.unpack('x4 VVvv')
|
367
|
+
alist = @dims.zip(vals)
|
368
|
+
results = Hash[*alist.flatten]
|
369
|
+
|
370
|
+
alist = @dims.zip([5, 6, 3, 4])
|
371
|
+
expected = Hash[*alist.flatten]
|
372
|
+
|
373
|
+
assert_equal(expected, results)
|
374
|
+
end
|
375
|
+
|
376
|
+
def test_merge_range
|
377
|
+
formula = @worksheet.store_formula('=A1 * 3 + 50')
|
378
|
+
@worksheet.merge_range('C6:E8', 'Test', @format)
|
379
|
+
|
380
|
+
data = @worksheet.store_dimensions
|
381
|
+
|
382
|
+
vals = data.unpack('x4 VVvv')
|
383
|
+
alist = @dims.zip(vals)
|
384
|
+
results = Hash[*alist.flatten]
|
385
|
+
|
386
|
+
alist = @dims.zip([5, 8, 2, 5])
|
387
|
+
expected = Hash[*alist.flatten]
|
388
|
+
|
389
|
+
assert_equal(expected, results)
|
390
|
+
end
|
391
|
+
|
392
|
+
end
|