roo 1.9.3 → 1.9.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +12 -0
- data/README.txt +3 -0
- data/Rakefile +31 -95
- data/TODO +2 -0
- data/a.xls +0 -0
- data/bin/roo +1 -1
- data/lib/roo.rb +2 -1
- data/lib/roo/.generic_spreadsheet.rb.rb.swp +0 -0
- data/lib/roo/excel.rb +33 -6
- data/lib/roo/excelx.rb +16 -5
- data/lib/roo/generic_spreadsheet.rb +53 -73
- data/lib/roo/google.rb +330 -325
- data/lib/roo/openoffice.rb +520 -503
- data/rm_sub_test.rb +13 -0
- data/rm_test.rb +20 -0
- data/test/Bibelbund.csv +0 -0
- data/test/bode-v1.ods.zip +0 -0
- data/test/bode-v1.xls.zip +0 -0
- data/test/formula_string_error.xlsx +0 -0
- data/test/style.xls +0 -0
- data/test/test_helper.rb +30 -0
- data/test/test_roo.rb +2254 -2022
- data/test/type_excel.ods +0 -0
- data/test/type_excel.xlsx +0 -0
- data/test/type_excelx.ods +0 -0
- data/test/type_excelx.xls +0 -0
- data/test/type_openoffice.xls +0 -0
- data/test/type_openoffice.xlsx +0 -0
- data/tmp.xls +0 -0
- data/{csv9419 → tmpBibelbund.csv} +3741 -3741
- data/tmp_output.xml +85 -0
- data/{test/numbers1.csv → tmpnumbers1.csv} +18 -18
- metadata +93 -51
- data/csv11159 +0 -2888
- data/csv1414 +0 -2525
- data/csv9957 +0 -915
- data/test/ScienceStaff.xls +0 -0
- data/test/ScienceStaff_modified.xls +0 -0
- data/test/test_spreadsheet.rb +0 -19
data/rm_sub_test.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Loeschen von Dateien, wenn mit Excel geoeffnet
|
2
|
+
require 'rubygems'
|
3
|
+
require 'roo'
|
4
|
+
|
5
|
+
oo = Excel.new("tmp.xls")
|
6
|
+
#oo = Openoffice.new("tmp.ods")
|
7
|
+
oo.default_sheet = oo.sheets.first
|
8
|
+
oo.first_row.upto(oo.last_row) do |row|
|
9
|
+
oo.first_column.upto(oo.last_column) do |col|
|
10
|
+
p oo.cell(row,col)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
data/rm_test.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
=begin
|
2
|
+
require 'rubygems'
|
3
|
+
require 'roo'
|
4
|
+
|
5
|
+
oo = Excel.new("tmp.xls")
|
6
|
+
oo.default_sheet = oo.sheets.first
|
7
|
+
oo.first_row.upto(oo.last_row) do |row|
|
8
|
+
oo.first_column.upto(oo.last_column) do |col|
|
9
|
+
p oo.cell(row,col)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
FileUtils.rm_f("tmp.xls", {:verbose => true, :force => true})
|
13
|
+
=end
|
14
|
+
require 'spreadsheet'
|
15
|
+
|
16
|
+
book = Spreadsheet.open 'tmp.xls'
|
17
|
+
sheet = book.worksheet 0
|
18
|
+
sheet.each do |row| puts row[0] end
|
19
|
+
|
20
|
+
FileUtils.rm("tmp.xls")
|
data/test/Bibelbund.csv
CHANGED
File without changes
|
data/test/bode-v1.ods.zip
CHANGED
File without changes
|
data/test/bode-v1.xls.zip
CHANGED
File without changes
|
Binary file
|
data/test/style.xls
CHANGED
File without changes
|
data/test/test_helper.rb
CHANGED
@@ -17,3 +17,33 @@ def local_only
|
|
17
17
|
yield
|
18
18
|
end
|
19
19
|
end
|
20
|
+
|
21
|
+
# very simple diff implementation
|
22
|
+
# output is an empty string if the files are equal
|
23
|
+
# otherwise differences a printen (not compatible to
|
24
|
+
# the diff command)
|
25
|
+
def diff(fn1,fn2)
|
26
|
+
result = ''
|
27
|
+
f1 = File.open(fn1)
|
28
|
+
f2 = File.open(fn2)
|
29
|
+
while f1.eof? == false and f2.eof? == false
|
30
|
+
line1 = f1.gets
|
31
|
+
line2 = f2.gets
|
32
|
+
result << "<#{line1}\n>#{line2}\n" if line1 != line2
|
33
|
+
end
|
34
|
+
if f1.eof? == false
|
35
|
+
while f1.eof? == false
|
36
|
+
line1 = f1.gets
|
37
|
+
result << "<#{line1}\n"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
if f2.eof? == false
|
41
|
+
while f2.eof? == false
|
42
|
+
line2 = f2.gets
|
43
|
+
result ">#{line2}\n"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
f1.close
|
47
|
+
f2.close
|
48
|
+
result
|
49
|
+
end
|
data/test/test_roo.rb
CHANGED
@@ -1,2022 +1,2254 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# damit keine falschen Vermutungen aufkommen: Ich habe religioes rein gar nichts
|
3
|
-
# mit diesem Bibelbund zu tun, aber die hatten eine ziemlich grosse
|
4
|
-
# Spreadsheet-Datei mit ca. 3500 Zeilen oeffentlich im Netz, die sich ganz gut
|
5
|
-
# zum Testen eignete.
|
6
|
-
#
|
7
|
-
#--
|
8
|
-
# these test cases were developed to run under Linux OS, some commands
|
9
|
-
# (like 'diff') must be changed (or commented out ;-)) if you want to run
|
10
|
-
# the tests under another OS
|
11
|
-
#
|
12
|
-
require '
|
13
|
-
|
14
|
-
#
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
#
|
19
|
-
#
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
require '
|
25
|
-
require '
|
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
|
-
|
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
|
-
end
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
if
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
end
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
end
|
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
|
-
oo
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
oo
|
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
|
-
assert_equal 2, oo.
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
assert_equal
|
261
|
-
assert_equal
|
262
|
-
assert_equal
|
263
|
-
assert_equal
|
264
|
-
assert_equal
|
265
|
-
assert_equal
|
266
|
-
assert_equal
|
267
|
-
assert_equal
|
268
|
-
assert_equal
|
269
|
-
assert_equal "
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
assert_equal
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
assert_equal
|
282
|
-
assert_equal
|
283
|
-
assert_equal
|
284
|
-
assert_equal
|
285
|
-
assert_equal "
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
assert_equal
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
assert_equal "
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
assert_equal
|
309
|
-
assert_equal
|
310
|
-
assert_equal
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
assert_equal "
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
assert_equal
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
assert_equal
|
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
|
-
assert_raise(RangeError) { dummy = oo.
|
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
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
oo.
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
oo.
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
assert_equal
|
467
|
-
assert_equal
|
468
|
-
assert_equal
|
469
|
-
assert_equal
|
470
|
-
assert_equal
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
assert_equal
|
479
|
-
assert_equal
|
480
|
-
assert_equal
|
481
|
-
|
482
|
-
|
483
|
-
assert_equal
|
484
|
-
assert_equal
|
485
|
-
assert_equal
|
486
|
-
|
487
|
-
|
488
|
-
assert_equal
|
489
|
-
assert_equal
|
490
|
-
assert_equal
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
assert_equal "
|
495
|
-
assert_equal "
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
oo.
|
530
|
-
assert_equal
|
531
|
-
oo.
|
532
|
-
assert_equal
|
533
|
-
oo.
|
534
|
-
assert_equal
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
assert_equal
|
547
|
-
|
548
|
-
assert_equal
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
# assert_equal
|
564
|
-
|
565
|
-
|
566
|
-
#
|
567
|
-
#
|
568
|
-
assert_equal
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
assert_equal
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
assert_equal
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
assert_equal
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
oo.
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
oo.
|
623
|
-
assert_equal
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
assert_equal
|
631
|
-
assert_equal
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
assert_equal
|
652
|
-
assert_equal
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
assert_equal
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
end
|
720
|
-
end
|
721
|
-
end
|
722
|
-
|
723
|
-
def
|
724
|
-
|
725
|
-
begin
|
726
|
-
oo =
|
727
|
-
assert oo
|
728
|
-
assert_equal 'ist "e" im Nenner von H(s)', oo.cell('b', 5)
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
assert_equal '
|
757
|
-
assert_equal '
|
758
|
-
assert_equal 'B', oo.cell('
|
759
|
-
assert_equal '
|
760
|
-
assert_equal
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
assert_equal 'B', oo.cell('
|
765
|
-
assert_equal 'B', oo.cell('
|
766
|
-
assert_equal 'B', oo.cell('
|
767
|
-
assert_equal 'B', oo.cell('
|
768
|
-
assert_equal 'B', oo.cell('
|
769
|
-
assert_equal 'B', oo.cell('
|
770
|
-
assert_equal 'B', oo.cell('
|
771
|
-
|
772
|
-
|
773
|
-
assert_equal
|
774
|
-
assert_equal
|
775
|
-
assert_equal
|
776
|
-
assert_equal
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
assert_equal
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
assert_equal
|
914
|
-
assert_equal
|
915
|
-
assert_equal "
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
"
|
1012
|
-
"
|
1013
|
-
"
|
1014
|
-
"
|
1015
|
-
"
|
1016
|
-
|
1017
|
-
"
|
1018
|
-
|
1019
|
-
"
|
1020
|
-
"
|
1021
|
-
"
|
1022
|
-
"
|
1023
|
-
"
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
assert_equal
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
"
|
1041
|
-
"
|
1042
|
-
|
1043
|
-
|
1044
|
-
"
|
1045
|
-
"
|
1046
|
-
"
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
"
|
1051
|
-
"
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
assert_equal
|
1138
|
-
assert_equal '
|
1139
|
-
assert_equal
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
def
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
"
|
1193
|
-
|
1194
|
-
"
|
1195
|
-
|
1196
|
-
"
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
oo.
|
1304
|
-
|
1305
|
-
assert_equal
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
end
|
1398
|
-
end
|
1399
|
-
|
1400
|
-
def
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
}
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
assert_raises(
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1670
|
-
|
1671
|
-
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
1697
|
-
|
1698
|
-
|
1699
|
-
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1715
|
-
assert_equal
|
1716
|
-
assert_equal
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
with_each_spreadsheet(:name=>'
|
1726
|
-
|
1727
|
-
assert_equal
|
1728
|
-
assert_equal
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1735
|
-
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
assert_equal
|
1741
|
-
assert_equal
|
1742
|
-
assert_equal
|
1743
|
-
|
1744
|
-
|
1745
|
-
assert_equal
|
1746
|
-
|
1747
|
-
assert_equal
|
1748
|
-
|
1749
|
-
|
1750
|
-
assert_equal
|
1751
|
-
assert_equal
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
assert_equal
|
1756
|
-
assert_equal
|
1757
|
-
assert_equal
|
1758
|
-
|
1759
|
-
|
1760
|
-
assert_equal
|
1761
|
-
assert_equal
|
1762
|
-
assert_equal
|
1763
|
-
|
1764
|
-
|
1765
|
-
assert_equal
|
1766
|
-
assert_equal
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
assert_equal
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
1780
|
-
assert_equal
|
1781
|
-
assert_equal
|
1782
|
-
assert_equal
|
1783
|
-
|
1784
|
-
|
1785
|
-
assert_equal
|
1786
|
-
assert_equal
|
1787
|
-
assert_equal
|
1788
|
-
|
1789
|
-
|
1790
|
-
assert_equal
|
1791
|
-
assert_equal
|
1792
|
-
assert_equal
|
1793
|
-
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
|
1799
|
-
def
|
1800
|
-
with_each_spreadsheet(:name=>'
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1813
|
-
oo.
|
1814
|
-
assert_equal
|
1815
|
-
|
1816
|
-
assert_equal
|
1817
|
-
assert_equal
|
1818
|
-
|
1819
|
-
|
1820
|
-
|
1821
|
-
|
1822
|
-
|
1823
|
-
|
1824
|
-
|
1825
|
-
|
1826
|
-
|
1827
|
-
|
1828
|
-
|
1829
|
-
|
1830
|
-
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
1836
|
-
|
1837
|
-
|
1838
|
-
|
1839
|
-
|
1840
|
-
|
1841
|
-
|
1842
|
-
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
1850
|
-
|
1851
|
-
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1855
|
-
assert_equal
|
1856
|
-
|
1857
|
-
#
|
1858
|
-
|
1859
|
-
|
1860
|
-
assert_equal
|
1861
|
-
|
1862
|
-
|
1863
|
-
assert_equal
|
1864
|
-
|
1865
|
-
|
1866
|
-
|
1867
|
-
|
1868
|
-
|
1869
|
-
|
1870
|
-
|
1871
|
-
|
1872
|
-
|
1873
|
-
|
1874
|
-
|
1875
|
-
|
1876
|
-
|
1877
|
-
|
1878
|
-
|
1879
|
-
|
1880
|
-
|
1881
|
-
|
1882
|
-
|
1883
|
-
|
1884
|
-
|
1885
|
-
|
1886
|
-
|
1887
|
-
|
1888
|
-
|
1889
|
-
|
1890
|
-
|
1891
|
-
|
1892
|
-
|
1893
|
-
|
1894
|
-
|
1895
|
-
|
1896
|
-
|
1897
|
-
|
1898
|
-
|
1899
|
-
|
1900
|
-
|
1901
|
-
|
1902
|
-
|
1903
|
-
|
1904
|
-
|
1905
|
-
|
1906
|
-
|
1907
|
-
|
1908
|
-
|
1909
|
-
|
1910
|
-
|
1911
|
-
|
1912
|
-
|
1913
|
-
|
1914
|
-
|
1915
|
-
|
1916
|
-
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
1921
|
-
|
1922
|
-
|
1923
|
-
|
1924
|
-
|
1925
|
-
|
1926
|
-
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
1933
|
-
|
1934
|
-
|
1935
|
-
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1939
|
-
|
1940
|
-
|
1941
|
-
|
1942
|
-
|
1943
|
-
|
1944
|
-
|
1945
|
-
|
1946
|
-
|
1947
|
-
|
1948
|
-
|
1949
|
-
|
1950
|
-
|
1951
|
-
|
1952
|
-
|
1953
|
-
|
1954
|
-
|
1955
|
-
|
1956
|
-
|
1957
|
-
|
1958
|
-
|
1959
|
-
|
1960
|
-
|
1961
|
-
end
|
1962
|
-
end
|
1963
|
-
|
1964
|
-
|
1965
|
-
|
1966
|
-
|
1967
|
-
|
1968
|
-
|
1969
|
-
|
1970
|
-
|
1971
|
-
|
1972
|
-
|
1973
|
-
|
1974
|
-
|
1975
|
-
|
1976
|
-
|
1977
|
-
|
1978
|
-
|
1979
|
-
|
1980
|
-
|
1981
|
-
|
1982
|
-
|
1983
|
-
|
1984
|
-
|
1985
|
-
|
1986
|
-
|
1987
|
-
|
1988
|
-
|
1989
|
-
|
1990
|
-
|
1991
|
-
|
1992
|
-
|
1993
|
-
|
1994
|
-
|
1995
|
-
|
1996
|
-
|
1997
|
-
|
1998
|
-
|
1999
|
-
|
2000
|
-
|
2001
|
-
|
2002
|
-
|
2003
|
-
|
2004
|
-
|
2005
|
-
|
2006
|
-
|
2007
|
-
|
2008
|
-
|
2009
|
-
|
2010
|
-
|
2011
|
-
|
2012
|
-
|
2013
|
-
|
2014
|
-
|
2015
|
-
|
2016
|
-
|
2017
|
-
|
2018
|
-
|
2019
|
-
|
2020
|
-
|
2021
|
-
|
2022
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
# damit keine falschen Vermutungen aufkommen: Ich habe religioes rein gar nichts
|
3
|
+
# mit diesem Bibelbund zu tun, aber die hatten eine ziemlich grosse
|
4
|
+
# Spreadsheet-Datei mit ca. 3500 Zeilen oeffentlich im Netz, die sich ganz gut
|
5
|
+
# zum Testen eignete.
|
6
|
+
#
|
7
|
+
#--
|
8
|
+
# these test cases were developed to run under Linux OS, some commands
|
9
|
+
# (like 'diff') must be changed (or commented out ;-)) if you want to run
|
10
|
+
# the tests under another OS
|
11
|
+
#
|
12
|
+
require 'tmpdir'
|
13
|
+
require './lib/roo'
|
14
|
+
#TODO
|
15
|
+
# Look at formulas in excel - does not work with date/time
|
16
|
+
|
17
|
+
|
18
|
+
# Dump warnings that come from the test to open files
|
19
|
+
# with the wrong spreadsheet class
|
20
|
+
#STDERR.reopen "/dev/null","w"
|
21
|
+
|
22
|
+
TESTDIR = File.dirname(__FILE__)
|
23
|
+
TMP_PREFIX = 'oo_*'
|
24
|
+
# require './' + TESTDIR + '/test_helper.rb'
|
25
|
+
require TESTDIR + '/test_helper.rb'
|
26
|
+
|
27
|
+
#require 'soap/rpc/driver'
|
28
|
+
require 'fileutils'
|
29
|
+
require 'timeout'
|
30
|
+
require 'logger'
|
31
|
+
$log = Logger.new(File.join(ENV['HOME'],"roo.log"))
|
32
|
+
#$log.level = Logger::WARN
|
33
|
+
$log.level = Logger::DEBUG
|
34
|
+
|
35
|
+
DISPLAY_LOG = false
|
36
|
+
DB_LOG = false
|
37
|
+
if DB_LOG
|
38
|
+
require 'activerecord'
|
39
|
+
end
|
40
|
+
|
41
|
+
include FileUtils
|
42
|
+
def running_windows?
|
43
|
+
# to do
|
44
|
+
# "besser loesen"
|
45
|
+
# end
|
46
|
+
File.exists? "C:\\"
|
47
|
+
end
|
48
|
+
|
49
|
+
if DB_LOG
|
50
|
+
def activerecord_connect
|
51
|
+
ActiveRecord::Base.establish_connection(:adapter => "mysql",
|
52
|
+
:database => "test_runs",
|
53
|
+
:host => "localhost",
|
54
|
+
:username => "root",
|
55
|
+
:socket => "/var/run/mysqld/mysqld.sock")
|
56
|
+
end
|
57
|
+
|
58
|
+
class Testrun < ActiveRecord::Base
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
class Test::Unit::TestCase
|
63
|
+
def key_of(spreadsheetname)
|
64
|
+
begin
|
65
|
+
|
66
|
+
return {
|
67
|
+
#'formula' => 'rt4Pw1WmjxFtyfrqqy94wPw',
|
68
|
+
'formula' => 'o10837434939102457526.3022866619437760118',
|
69
|
+
#"write.me" => 'r6m7HFlUOwst0RTUTuhQ0Ow',
|
70
|
+
"write.me" => '0AkCuGANLc3jFcHR1NmJiYWhOWnBZME4wUnJ4UWJXZHc',
|
71
|
+
#'numbers1' => "rYraCzjxTtkxw1NxHJgDU8Q",
|
72
|
+
'numbers1' => 'o10837434939102457526.4784396906364855777',
|
73
|
+
#'borders' => "r_nLYMft6uWg_PT9Rc2urXw",
|
74
|
+
'borders' => "o10837434939102457526.664868920231926255",
|
75
|
+
#'simple_spreadsheet' => "r3aMMCBCA153TmU_wyIaxfw",
|
76
|
+
'simple_spreadsheet' => "ptu6bbahNZpYe-L1vEBmgGA",
|
77
|
+
'testnichtvorhandenBibelbund.ods' => "invalidkeyforanyspreadsheet", # !!! intentionally false key
|
78
|
+
#"only_one_sheet" => "rqRtkcPJ97nhQ0m9ksDw2rA",
|
79
|
+
"only_one_sheet" => "o10837434939102457526.762705759906130135",
|
80
|
+
#'time-test' => 'r2XfDBJMrLPjmuLrPQQrEYw',
|
81
|
+
'time-test' => 'ptu6bbahNZpYBMhk01UfXSg',
|
82
|
+
#'datetime' => "r2kQpXWr6xOSUpw9MyXavYg",
|
83
|
+
'datetime' => "ptu6bbahNZpYQEtZwzL_dZQ",
|
84
|
+
'whitespace' => "rZyQaoFebVGeHKzjG6e9gRQ",
|
85
|
+
'matrix' => '0AkCuGANLc3jFdHY3cWtYUkM4bVdadjZ5VGpfTzFEUEE',
|
86
|
+
}[spreadsheetname]
|
87
|
+
# 'numbers1' => "o10837434939102457526.4784396906364855777",
|
88
|
+
# 'borders' => "o10837434939102457526.664868920231926255",
|
89
|
+
# 'simple_spreadsheet' => "ptu6bbahNZpYe-L1vEBmgGA",
|
90
|
+
# 'testnichtvorhandenBibelbund.ods' => "invalidkeyforanyspreadsheet", # !!! intentionally false key
|
91
|
+
# "only_one_sheet" => "o10837434939102457526.762705759906130135",
|
92
|
+
# "write.me" => 'ptu6bbahNZpY0N0RrxQbWdw&hl',
|
93
|
+
# 'formula' => 'o10837434939102457526.3022866619437760118',
|
94
|
+
# 'time-test' => 'ptu6bbahNZpYBMhk01UfXSg',
|
95
|
+
# 'datetime' => "ptu6bbahNZpYQEtZwzL_dZQ",
|
96
|
+
rescue
|
97
|
+
raise "unknown spreadsheetname: #{spreadsheetname}"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
if DB_LOG
|
102
|
+
if ! (defined?(@connected) and @connected)
|
103
|
+
activerecord_connect
|
104
|
+
else
|
105
|
+
@connected = true
|
106
|
+
end
|
107
|
+
end
|
108
|
+
alias unlogged_run run
|
109
|
+
def run(result, &block)
|
110
|
+
t1 = Time.now
|
111
|
+
#RAILS_DEFAULT_LOGGER.debug "RUNNING #{self.class} #{@method_name} \t#{Time.now.to_s}"
|
112
|
+
if DISPLAY_LOG
|
113
|
+
v1,v2,v3 = RUBY_VERSION.split('.')
|
114
|
+
if v1.to_i > 1 or
|
115
|
+
(v1.to_i == 1 and v2.to_i > 8)
|
116
|
+
# Ruby 1.9.x
|
117
|
+
print "RUNNING #{self.class} #{self.__name__} \t#{Time.now.to_s}"
|
118
|
+
else
|
119
|
+
# Ruby < 1.9.x
|
120
|
+
print "RUNNING #{self.class} #{@method_name} \t#{Time.now.to_s}"
|
121
|
+
end
|
122
|
+
STDOUT.flush
|
123
|
+
end
|
124
|
+
unlogged_run result, &block
|
125
|
+
t2 = Time.now
|
126
|
+
if DISPLAY_LOG
|
127
|
+
puts "\t#{t2-t1} seconds"
|
128
|
+
end
|
129
|
+
if DB_LOG
|
130
|
+
domain = Testrun.create(
|
131
|
+
:class_name => self.class.to_s,
|
132
|
+
:test_name => @method_name,
|
133
|
+
:start => t1,
|
134
|
+
:duration => t2-t1
|
135
|
+
)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
class File
|
141
|
+
def File.delete_if_exist(filename)
|
142
|
+
if File.exist?(filename)
|
143
|
+
File.delete(filename)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
# :nodoc
|
149
|
+
class Fixnum
|
150
|
+
def minutes
|
151
|
+
self * 60
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
class TestRoo < Test::Unit::TestCase
|
156
|
+
|
157
|
+
OPENOFFICE = true # do Openoffice-Spreadsheet Tests? (.ods files)
|
158
|
+
EXCEL = true # do Excel Tests? (.xls files)
|
159
|
+
GOOGLE = true # do Google-Spreadsheet Tests?
|
160
|
+
EXCELX = true # do Excelx Tests? (.xlsx files)
|
161
|
+
|
162
|
+
ONLINE = true
|
163
|
+
LONG_RUN = true
|
164
|
+
GLOBAL_TIMEOUT = 48.minutes
|
165
|
+
|
166
|
+
def setup
|
167
|
+
#if DISPLAY_LOG
|
168
|
+
# puts " GLOBAL_TIMEOUT = #{GLOBAL_TIMEOUT}"
|
169
|
+
#end
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_internal_minutes
|
173
|
+
assert_equal 42*60, 42.minutes
|
174
|
+
end
|
175
|
+
|
176
|
+
# call a block of code for each spreadsheet type
|
177
|
+
# and yield a reference to the roo object
|
178
|
+
def with_each_spreadsheet(options)
|
179
|
+
# test if the spreadsheet type is valid :nodoc
|
180
|
+
if options[:format]
|
181
|
+
if options[:format].is_a? Symbol
|
182
|
+
options[:format] = [options[:format]]
|
183
|
+
end
|
184
|
+
options[:format].each do |formatname|
|
185
|
+
unless [:openoffice,:excel,:excelx,:google].include?(formatname)
|
186
|
+
raise "invalid spreadsheet type #{formatname}"
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
# end test spreadsheet type :nodoc
|
191
|
+
options[:format] ||= [:excel, :excelx, :openoffice, :google]
|
192
|
+
options[:format] = [options[:format]] if options[:format].class == Symbol
|
193
|
+
yield Roo::Spreadsheet.open(File.join(TESTDIR, options[:name] + '.xls')) if EXCEL && options[:format].include?(:excel)
|
194
|
+
yield Roo::Spreadsheet.open(File.join(TESTDIR, options[:name] + '.xlsx')) if EXCELX && options[:format].include?(:excelx)
|
195
|
+
yield Roo::Spreadsheet.open(File.join(TESTDIR, options[:name] + '.ods')) if OPENOFFICE && options[:format].include?(:openoffice)
|
196
|
+
yield Roo::Spreadsheet.open(key_of(options[:name]) || options[:name]) if GOOGLE && options[:format].include?(:google)
|
197
|
+
end
|
198
|
+
# Using Date.strptime so check that it's using the method
|
199
|
+
# with the value set in date_format
|
200
|
+
def test_date
|
201
|
+
with_each_spreadsheet(:name=>'numbers1', :format=>:google) do |oo|
|
202
|
+
# should default to DDMMYYYY
|
203
|
+
assert oo.date?("21/11/1962")
|
204
|
+
assert !oo.date?("11/21/1962")
|
205
|
+
oo.date_format = '%m/%d/%Y'
|
206
|
+
assert !oo.date?("21/11/1962")
|
207
|
+
assert oo.date?("11/21/1962")
|
208
|
+
oo.date_format = '%Y-%m-%d'
|
209
|
+
assert(oo.date?("1962-11-21"))
|
210
|
+
assert(!oo.date?("1962-21-11"))
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
def test_classes
|
215
|
+
if OPENOFFICE
|
216
|
+
oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
|
217
|
+
assert_kind_of Openoffice, oo
|
218
|
+
end
|
219
|
+
if EXCEL
|
220
|
+
oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
|
221
|
+
assert_kind_of Excel, oo
|
222
|
+
end
|
223
|
+
if GOOGLE
|
224
|
+
oo = Google.new(key_of("numbers1"))
|
225
|
+
assert_kind_of Google, oo
|
226
|
+
end
|
227
|
+
if EXCELX
|
228
|
+
oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
|
229
|
+
assert_kind_of Excelx, oo
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
def test_letters
|
234
|
+
assert_equal 1, GenericSpreadsheet.letter_to_number('A')
|
235
|
+
assert_equal 1, GenericSpreadsheet.letter_to_number('a')
|
236
|
+
assert_equal 2, GenericSpreadsheet.letter_to_number('B')
|
237
|
+
assert_equal 26, GenericSpreadsheet.letter_to_number('Z')
|
238
|
+
assert_equal 27, GenericSpreadsheet.letter_to_number('AA')
|
239
|
+
assert_equal 27, GenericSpreadsheet.letter_to_number('aA')
|
240
|
+
assert_equal 27, GenericSpreadsheet.letter_to_number('Aa')
|
241
|
+
assert_equal 27, GenericSpreadsheet.letter_to_number('aa')
|
242
|
+
end
|
243
|
+
def test_sheets
|
244
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
245
|
+
assert_equal ["Tabelle1","Name of Sheet 2","Sheet3","Sheet4","Sheet5"], oo.sheets
|
246
|
+
assert_raise(RangeError) { oo.default_sheet = "no_sheet" }
|
247
|
+
assert_raise(TypeError) { oo.default_sheet = [1,2,3] }
|
248
|
+
oo.sheets.each { |sh|
|
249
|
+
oo.default_sheet = sh
|
250
|
+
assert_equal sh, oo.default_sheet
|
251
|
+
}
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
def test_cells
|
256
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
257
|
+
# warum ist Auswaehlen erstes sheet hier nicht
|
258
|
+
# mehr drin?
|
259
|
+
oo.default_sheet = oo.sheets.first
|
260
|
+
assert_equal 1, oo.cell(1,1)
|
261
|
+
assert_equal 2, oo.cell(1,2)
|
262
|
+
assert_equal 3, oo.cell(1,3)
|
263
|
+
assert_equal 4, oo.cell(1,4)
|
264
|
+
assert_equal 5, oo.cell(2,1)
|
265
|
+
assert_equal 6, oo.cell(2,2)
|
266
|
+
assert_equal 7, oo.cell(2,3)
|
267
|
+
assert_equal 8, oo.cell(2,4)
|
268
|
+
assert_equal 9, oo.cell(2,5)
|
269
|
+
assert_equal "test", oo.cell(2,6)
|
270
|
+
assert_equal :string, oo.celltype(2,6)
|
271
|
+
assert_equal 11, oo.cell(2,7)
|
272
|
+
assert_equal :float, oo.celltype(2,7)
|
273
|
+
assert_equal 10, oo.cell(4,1)
|
274
|
+
assert_equal 11, oo.cell(4,2)
|
275
|
+
assert_equal 12, oo.cell(4,3)
|
276
|
+
assert_equal 13, oo.cell(4,4)
|
277
|
+
assert_equal 14, oo.cell(4,5)
|
278
|
+
assert_equal 10, oo.cell(4,'A')
|
279
|
+
assert_equal 11, oo.cell(4,'B')
|
280
|
+
assert_equal 12, oo.cell(4,'C')
|
281
|
+
assert_equal 13, oo.cell(4,'D')
|
282
|
+
assert_equal 14, oo.cell(4,'E')
|
283
|
+
assert_equal :date, oo.celltype(5,1)
|
284
|
+
assert_equal Date.new(1961,11,21), oo.cell(5,1)
|
285
|
+
assert_equal "1961-11-21", oo.cell(5,1).to_s
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
def test_celltype
|
290
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
291
|
+
assert_equal :string, oo.celltype(2,6)
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
def test_cell_address
|
296
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
297
|
+
assert_equal "tata", oo.cell(6,1)
|
298
|
+
assert_equal "tata", oo.cell(6,'A')
|
299
|
+
assert_equal "tata", oo.cell('A',6)
|
300
|
+
assert_equal "tata", oo.cell(6,'a')
|
301
|
+
assert_equal "tata", oo.cell('a',6)
|
302
|
+
assert_raise(ArgumentError) { assert_equal "tata", oo.cell('a','f') }
|
303
|
+
assert_raise(ArgumentError) { assert_equal "tata", oo.cell('f','a') }
|
304
|
+
assert_equal "thisisc8", oo.cell(8,3)
|
305
|
+
assert_equal "thisisc8", oo.cell(8,'C')
|
306
|
+
assert_equal "thisisc8", oo.cell('C',8)
|
307
|
+
assert_equal "thisisc8", oo.cell(8,'c')
|
308
|
+
assert_equal "thisisc8", oo.cell('c',8)
|
309
|
+
assert_equal "thisisd9", oo.cell('d',9)
|
310
|
+
assert_equal "thisisa11", oo.cell('a',11)
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
def test_office_version
|
315
|
+
with_each_spreadsheet(:name=>'numbers1', :format=>:openoffice) do |oo|
|
316
|
+
assert_equal "1.0", oo.officeversion
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
#TODO: inkonsequente Lieferung Fixnum/Float
|
321
|
+
def test_rows
|
322
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
323
|
+
oo.default_sheet = oo.sheets.first
|
324
|
+
assert_equal 41, oo.cell('a',12)
|
325
|
+
assert_equal 42, oo.cell('b',12)
|
326
|
+
assert_equal 43, oo.cell('c',12)
|
327
|
+
assert_equal 44, oo.cell('d',12)
|
328
|
+
assert_equal 45, oo.cell('e',12)
|
329
|
+
assert_equal [41.0,42.0,43.0,44.0,45.0, nil, nil], oo.row(12)
|
330
|
+
assert_equal "einundvierzig", oo.cell('a',16)
|
331
|
+
assert_equal "zweiundvierzig", oo.cell('b',16)
|
332
|
+
assert_equal "dreiundvierzig", oo.cell('c',16)
|
333
|
+
assert_equal "vierundvierzig", oo.cell('d',16)
|
334
|
+
assert_equal "fuenfundvierzig", oo.cell('e',16)
|
335
|
+
assert_equal ["einundvierzig", "zweiundvierzig", "dreiundvierzig", "vierundvierzig", "fuenfundvierzig", nil, nil], oo.row(16)
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
def test_last_row
|
340
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
341
|
+
oo.default_sheet = oo.sheets.first
|
342
|
+
assert_equal 18, oo.last_row
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
def test_last_column
|
347
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
348
|
+
oo.default_sheet = oo.sheets.first
|
349
|
+
assert_equal 7, oo.last_column
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
353
|
+
def test_last_column_as_letter
|
354
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
355
|
+
oo.default_sheet = oo.sheets.first
|
356
|
+
assert_equal 'G', oo.last_column_as_letter
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
def test_first_row
|
361
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
362
|
+
oo.default_sheet = oo.sheets.first
|
363
|
+
assert_equal 1, oo.first_row
|
364
|
+
end
|
365
|
+
end
|
366
|
+
|
367
|
+
def test_first_column
|
368
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
369
|
+
oo.default_sheet = oo.sheets.first
|
370
|
+
assert_equal 1, oo.first_column
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
def test_first_column_as_letter
|
375
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
376
|
+
oo.default_sheet = oo.sheets.first
|
377
|
+
assert_equal 'A', oo.first_column_as_letter
|
378
|
+
end
|
379
|
+
end
|
380
|
+
|
381
|
+
def test_sheetname
|
382
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
383
|
+
oo.default_sheet = "Name of Sheet 2"
|
384
|
+
assert_equal 'I am sheet 2', oo.cell('C',5)
|
385
|
+
assert_raise(RangeError) { oo.default_sheet = "non existing sheet name" }
|
386
|
+
assert_raise(RangeError) { oo.default_sheet = "non existing sheet name" }
|
387
|
+
assert_raise(RangeError) { dummy = oo.cell('C',5,"non existing sheet name")}
|
388
|
+
assert_raise(RangeError) { dummy = oo.celltype('C',5,"non existing sheet name")}
|
389
|
+
assert_raise(RangeError) { dummy = oo.empty?('C',5,"non existing sheet name")}
|
390
|
+
if oo.class == Excel
|
391
|
+
assert_raise(RuntimeError) { dummy = oo.formula?('C',5,"non existing sheet name")}
|
392
|
+
assert_raise(RuntimeError) { dummy = oo.formula('C',5,"non existing sheet name")}
|
393
|
+
else
|
394
|
+
assert_raise(RangeError) { dummy = oo.formula?('C',5,"non existing sheet name")}
|
395
|
+
assert_raise(RangeError) { dummy = oo.formula('C',5,"non existing sheet name")}
|
396
|
+
begin
|
397
|
+
assert_raise(RangeError) { dummy = oo.set('C',5,42,"non existing sheet name")} unless oo.class == Google
|
398
|
+
rescue NameError
|
399
|
+
#
|
400
|
+
end
|
401
|
+
assert_raise(RangeError) { dummy = oo.formulas("non existing sheet name")}
|
402
|
+
end
|
403
|
+
assert_raise(RangeError) { dummy = oo.to_yaml({},1,1,1,1,"non existing sheet name")}
|
404
|
+
end
|
405
|
+
end
|
406
|
+
|
407
|
+
def test_boundaries
|
408
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
409
|
+
oo.default_sheet = "Name of Sheet 2"
|
410
|
+
assert_equal 2, oo.first_column
|
411
|
+
assert_equal 'B', oo.first_column_as_letter
|
412
|
+
assert_equal 5, oo.first_row
|
413
|
+
assert_equal 'E', oo.last_column_as_letter
|
414
|
+
assert_equal 14, oo.last_row
|
415
|
+
end
|
416
|
+
end
|
417
|
+
|
418
|
+
def test_multiple_letters
|
419
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
420
|
+
oo.default_sheet = "Sheet3"
|
421
|
+
assert_equal "i am AA", oo.cell('AA',1)
|
422
|
+
assert_equal "i am AB", oo.cell('AB',1)
|
423
|
+
assert_equal "i am BA", oo.cell('BA',1)
|
424
|
+
assert_equal 'BA', oo.last_column_as_letter
|
425
|
+
assert_equal "i am BA", oo.cell(1,'BA')
|
426
|
+
end
|
427
|
+
end
|
428
|
+
|
429
|
+
def test_argument_error
|
430
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
431
|
+
assert_nothing_raised(ArgumentError) { oo.default_sheet = "Tabelle1" }
|
432
|
+
end
|
433
|
+
end
|
434
|
+
|
435
|
+
def test_empty_eh
|
436
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
437
|
+
assert oo.empty?('a',14)
|
438
|
+
assert ! oo.empty?('a',15)
|
439
|
+
assert oo.empty?('a',20)
|
440
|
+
end
|
441
|
+
end
|
442
|
+
|
443
|
+
def test_reload
|
444
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
445
|
+
oo.default_sheet = oo.sheets.first
|
446
|
+
assert_equal 1, oo.cell(1,1)
|
447
|
+
oo.reload
|
448
|
+
assert_equal 1, oo.cell(1,1)
|
449
|
+
end
|
450
|
+
end
|
451
|
+
|
452
|
+
def test_bug_contiguous_cells
|
453
|
+
with_each_spreadsheet(:name=>'numbers1', :format=>:openoffice) do |oo|
|
454
|
+
oo.default_sheet = "Sheet4"
|
455
|
+
assert_equal Date.new(2007,06,16), oo.cell('a',1)
|
456
|
+
assert_equal 10, oo.cell('b',1)
|
457
|
+
assert_equal 10, oo.cell('c',1)
|
458
|
+
assert_equal 10, oo.cell('d',1)
|
459
|
+
assert_equal 10, oo.cell('e',1)
|
460
|
+
end
|
461
|
+
end
|
462
|
+
|
463
|
+
def test_bug_italo_ve
|
464
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
465
|
+
oo.default_sheet = "Sheet5"
|
466
|
+
assert_equal 1, oo.cell('A',1)
|
467
|
+
assert_equal 5, oo.cell('b',1)
|
468
|
+
assert_equal 5, oo.cell('c',1)
|
469
|
+
assert_equal 2, oo.cell('a',2)
|
470
|
+
assert_equal 3, oo.cell('a',3)
|
471
|
+
end
|
472
|
+
end
|
473
|
+
|
474
|
+
def test_italo_table
|
475
|
+
with_each_spreadsheet(:name=>'simple_spreadsheet_from_italo', :format=>[:openoffice, :excel]) do |oo|
|
476
|
+
assert_equal '1', oo.cell('A',1)
|
477
|
+
assert_equal '1', oo.cell('B',1)
|
478
|
+
assert_equal '1', oo.cell('C',1)
|
479
|
+
assert_equal 1, oo.cell('A',2).to_i
|
480
|
+
assert_equal 2, oo.cell('B',2).to_i
|
481
|
+
assert_equal 1, oo.cell('C',2).to_i
|
482
|
+
assert_equal 1, oo.cell('A',3)
|
483
|
+
assert_equal 3, oo.cell('B',3)
|
484
|
+
assert_equal 1, oo.cell('C',3)
|
485
|
+
assert_equal 'A', oo.cell('A',4)
|
486
|
+
assert_equal 'A', oo.cell('B',4)
|
487
|
+
assert_equal 'A', oo.cell('C',4)
|
488
|
+
assert_equal 0.01, oo.cell('A',5)
|
489
|
+
assert_equal 0.01, oo.cell('B',5)
|
490
|
+
assert_equal 0.01, oo.cell('C',5)
|
491
|
+
assert_equal 0.03, oo.cell('a',5)+oo.cell('b',5)+oo.cell('c',5)
|
492
|
+
|
493
|
+
# Cells values in row 1:
|
494
|
+
assert_equal "1:string", oo.cell(1, 1)+":"+oo.celltype(1, 1).to_s
|
495
|
+
assert_equal "1:string",oo.cell(1, 2)+":"+oo.celltype(1, 2).to_s
|
496
|
+
assert_equal "1:string",oo.cell(1, 3)+":"+oo.celltype(1, 3).to_s
|
497
|
+
|
498
|
+
# Cells values in row 2:
|
499
|
+
assert_equal "1:string",oo.cell(2, 1)+":"+oo.celltype(2, 1).to_s
|
500
|
+
assert_equal "2:string",oo.cell(2, 2)+":"+oo.celltype(2, 2).to_s
|
501
|
+
assert_equal "1:string",oo.cell(2, 3)+":"+oo.celltype(2, 3).to_s
|
502
|
+
|
503
|
+
# Cells values in row 3:
|
504
|
+
assert_equal "1.0:float",oo.cell(3, 1).to_s+":"+oo.celltype(3, 1).to_s
|
505
|
+
assert_equal "3.0:float",oo.cell(3, 2).to_s+":"+oo.celltype(3, 2).to_s
|
506
|
+
assert_equal "1.0:float",oo.cell(3, 3).to_s+":"+oo.celltype(3, 3).to_s
|
507
|
+
|
508
|
+
# Cells values in row 4:
|
509
|
+
assert_equal "A:string",oo.cell(4, 1)+":"+oo.celltype(4, 1).to_s
|
510
|
+
assert_equal "A:string",oo.cell(4, 2)+":"+oo.celltype(4, 2).to_s
|
511
|
+
assert_equal "A:string",oo.cell(4, 3)+":"+oo.celltype(4, 3).to_s
|
512
|
+
|
513
|
+
# Cells values in row 5:
|
514
|
+
if oo.class == Openoffice
|
515
|
+
assert_equal "0.01:percentage",oo.cell(5, 1).to_s+":"+oo.celltype(5, 1).to_s
|
516
|
+
assert_equal "0.01:percentage",oo.cell(5, 2).to_s+":"+oo.celltype(5, 2).to_s
|
517
|
+
assert_equal "0.01:percentage",oo.cell(5, 3).to_s+":"+oo.celltype(5, 3).to_s
|
518
|
+
else
|
519
|
+
assert_equal "0.01:float",oo.cell(5, 1).to_s+":"+oo.celltype(5, 1).to_s
|
520
|
+
assert_equal "0.01:float",oo.cell(5, 2).to_s+":"+oo.celltype(5, 2).to_s
|
521
|
+
assert_equal "0.01:float",oo.cell(5, 3).to_s+":"+oo.celltype(5, 3).to_s
|
522
|
+
end
|
523
|
+
end
|
524
|
+
end
|
525
|
+
|
526
|
+
def test_formula_openoffice
|
527
|
+
with_each_spreadsheet(:name=>'formula', :format=>:openoffice) do |oo|
|
528
|
+
assert_equal 1, oo.cell('A',1)
|
529
|
+
assert_equal 2, oo.cell('A',2)
|
530
|
+
assert_equal 3, oo.cell('A',3)
|
531
|
+
assert_equal 4, oo.cell('A',4)
|
532
|
+
assert_equal 5, oo.cell('A',5)
|
533
|
+
assert_equal 6, oo.cell('A',6)
|
534
|
+
assert_equal 21, oo.cell('A',7)
|
535
|
+
assert_equal :formula, oo.celltype('A',7)
|
536
|
+
assert_equal "=[Sheet2.A1]", oo.formula('C',7)
|
537
|
+
assert_nil oo.formula('A',6)
|
538
|
+
assert_equal [[7, 1, "=SUM([.A1:.A6])"],
|
539
|
+
[7, 2, "=SUM([.$A$1:.B6])"],
|
540
|
+
[7, 3, "=[Sheet2.A1]"],
|
541
|
+
[8, 2, "=SUM([.$A$1:.B7])"],
|
542
|
+
], oo.formulas(oo.sheets.first)
|
543
|
+
|
544
|
+
# setting a cell
|
545
|
+
oo.set('A',15, 41)
|
546
|
+
assert_equal 41, oo.cell('A',15)
|
547
|
+
oo.set('A',16, "41")
|
548
|
+
assert_equal "41", oo.cell('A',16)
|
549
|
+
oo.set('A',17, 42.5)
|
550
|
+
assert_equal 42.5, oo.cell('A',17)
|
551
|
+
end
|
552
|
+
end
|
553
|
+
|
554
|
+
def test_formula_google
|
555
|
+
with_each_spreadsheet(:name=>'formula', :format=>:google) do |oo|
|
556
|
+
oo.default_sheet = oo.sheets.first
|
557
|
+
assert_equal 1, oo.cell('A',1)
|
558
|
+
assert_equal 2, oo.cell('A',2)
|
559
|
+
assert_equal 3, oo.cell('A',3)
|
560
|
+
assert_equal 4, oo.cell('A',4)
|
561
|
+
assert_equal 5, oo.cell('A',5)
|
562
|
+
assert_equal 6, oo.cell('A',6)
|
563
|
+
# assert_equal 21, oo.cell('A',7)
|
564
|
+
assert_equal 21.0, oo.cell('A',7) #TODO: better solution Fixnum/Float
|
565
|
+
assert_equal :formula, oo.celltype('A',7)
|
566
|
+
# assert_equal "=[Sheet2.A1]", oo.formula('C',7)
|
567
|
+
# !!! different from formulas in Openoffice
|
568
|
+
#was: assert_equal "=sheet2!R[-6]C[-2]", oo.formula('C',7)
|
569
|
+
# has Google changed their format of formulas/references to other sheets?
|
570
|
+
assert_equal "=Sheet2!R[-6]C[-2]", oo.formula('C',7)
|
571
|
+
assert_nil oo.formula('A',6)
|
572
|
+
# assert_equal [[7, 1, "=SUM([.A1:.A6])"],
|
573
|
+
# [7, 2, "=SUM([.$A$1:.B6])"],
|
574
|
+
# [7, 3, "=[Sheet2.A1]"],
|
575
|
+
# [8, 2, "=SUM([.$A$1:.B7])"],
|
576
|
+
# ], oo.formulas(oo.sheets.first)
|
577
|
+
# different format than in openoffice spreadsheets:
|
578
|
+
#was:
|
579
|
+
# assert_equal [[7, 1, "=SUM(R[-6]C[0]:R[-1]C[0])"],
|
580
|
+
# [7, 2, "=SUM(R1C1:R[-1]C[0])"],
|
581
|
+
# [7, 3, "=sheet2!R[-6]C[-2]"],
|
582
|
+
# [8, 2, "=SUM(R1C1:R[-1]C[0])"]],
|
583
|
+
# oo.formulas(oo.sheets.first)
|
584
|
+
assert_equal [[7, 1, "=SUM(R[-6]C:R[-1]C)"],
|
585
|
+
[7, 2, "=SUM(R1C1:R[-1]C)"],
|
586
|
+
[7, 3, "=Sheet2!R[-6]C[-2]"],
|
587
|
+
[8, 2, "=SUM(R1C1:R[-1]C)"]],
|
588
|
+
oo.formulas(oo.sheets.first)
|
589
|
+
end
|
590
|
+
end
|
591
|
+
|
592
|
+
def test_formula_excelx
|
593
|
+
with_each_spreadsheet(:name=>'formula', :format=>:excelx) do |oo|
|
594
|
+
assert_equal 1, oo.cell('A',1)
|
595
|
+
assert_equal 2, oo.cell('A',2)
|
596
|
+
assert_equal 3, oo.cell('A',3)
|
597
|
+
assert_equal 4, oo.cell('A',4)
|
598
|
+
assert_equal 5, oo.cell('A',5)
|
599
|
+
assert_equal 6, oo.cell('A',6)
|
600
|
+
assert_equal 21, oo.cell('A',7)
|
601
|
+
assert_equal :formula, oo.celltype('A',7)
|
602
|
+
#steht nicht in Datei, oder?
|
603
|
+
#nein, diesen Bezug habe ich nur in der Openoffice-Datei
|
604
|
+
#assert_equal "=[Sheet2.A1]", oo.formula('C',7)
|
605
|
+
assert_nil oo.formula('A',6)
|
606
|
+
# assert_equal [[7, 1, "=SUM([.A1:.A6])"],
|
607
|
+
# [7, 2, "=SUM([.$A$1:.B6])"],
|
608
|
+
#[7, 3, "=[Sheet2.A1]"],
|
609
|
+
#[8, 2, "=SUM([.$A$1:.B7])"],
|
610
|
+
#], oo.formulas(oo.sheets.first)
|
611
|
+
assert_equal [[7, 1, 'SUM(A1:A6)'],
|
612
|
+
[7, 2, 'SUM($A$1:B6)'],
|
613
|
+
# [7, 3, "=[Sheet2.A1]"],
|
614
|
+
# [8, 2, "=SUM([.$A$1:.B7])"],
|
615
|
+
], oo.formulas(oo.sheets.first)
|
616
|
+
|
617
|
+
# setting a cell
|
618
|
+
oo.set('A',15, 41)
|
619
|
+
assert_equal 41, oo.cell('A',15)
|
620
|
+
oo.set('A',16, "41")
|
621
|
+
assert_equal "41", oo.cell('A',16)
|
622
|
+
oo.set('A',17, 42.5)
|
623
|
+
assert_equal 42.5, oo.cell('A',17)
|
624
|
+
end
|
625
|
+
end
|
626
|
+
|
627
|
+
# Excel can only read the cell's value
|
628
|
+
def test_formula_excel
|
629
|
+
with_each_spreadsheet(:name=>'formula', :format=>:excel) do |oo|
|
630
|
+
assert_equal 21, oo.cell('A',7)
|
631
|
+
assert_equal 21, oo.cell('B',7)
|
632
|
+
end
|
633
|
+
end
|
634
|
+
|
635
|
+
|
636
|
+
def test_borders_sheets
|
637
|
+
with_each_spreadsheet(:name=>'borders') do |oo|
|
638
|
+
oo.default_sheet = oo.sheets[1]
|
639
|
+
assert_equal 6, oo.first_row
|
640
|
+
assert_equal 11, oo.last_row
|
641
|
+
assert_equal 4, oo.first_column
|
642
|
+
assert_equal 8, oo.last_column
|
643
|
+
|
644
|
+
oo.default_sheet = oo.sheets.first
|
645
|
+
assert_equal 5, oo.first_row
|
646
|
+
assert_equal 10, oo.last_row
|
647
|
+
assert_equal 3, oo.first_column
|
648
|
+
assert_equal 7, oo.last_column
|
649
|
+
|
650
|
+
oo.default_sheet = oo.sheets[2]
|
651
|
+
assert_equal 7, oo.first_row
|
652
|
+
assert_equal 12, oo.last_row
|
653
|
+
assert_equal 5, oo.first_column
|
654
|
+
assert_equal 9, oo.last_column
|
655
|
+
end
|
656
|
+
end
|
657
|
+
|
658
|
+
def yaml_entry(row,col,type,value)
|
659
|
+
"cell_#{row}_#{col}: \n row: #{row} \n col: #{col} \n celltype: #{type} \n value: #{value} \n"
|
660
|
+
end
|
661
|
+
|
662
|
+
def test_to_yaml
|
663
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
664
|
+
oo.default_sheet = oo.sheets.first
|
665
|
+
assert_equal "--- \n"+yaml_entry(5,1,"date","1961-11-21"), oo.to_yaml({}, 5,1,5,1)
|
666
|
+
assert_equal "--- \n"+yaml_entry(8,3,"string","thisisc8"), oo.to_yaml({}, 8,3,8,3)
|
667
|
+
assert_equal "--- \n"+yaml_entry(12,3,"float",43.0), oo.to_yaml({}, 12,3,12,3)
|
668
|
+
assert_equal \
|
669
|
+
"--- \n"+yaml_entry(12,3,"float",43.0) +
|
670
|
+
yaml_entry(12,4,"float",44.0) +
|
671
|
+
yaml_entry(12,5,"float",45.0), oo.to_yaml({}, 12,3,12)
|
672
|
+
assert_equal \
|
673
|
+
"--- \n"+yaml_entry(12,3,"float",43.0)+
|
674
|
+
yaml_entry(12,4,"float",44.0)+
|
675
|
+
yaml_entry(12,5,"float",45.0)+
|
676
|
+
yaml_entry(15,3,"float",43.0)+
|
677
|
+
yaml_entry(15,4,"float",44.0)+
|
678
|
+
yaml_entry(15,5,"float",45.0)+
|
679
|
+
yaml_entry(16,3,"string","dreiundvierzig")+
|
680
|
+
yaml_entry(16,4,"string","vierundvierzig")+
|
681
|
+
yaml_entry(16,5,"string","fuenfundvierzig"), oo.to_yaml({}, 12,3)
|
682
|
+
end
|
683
|
+
end
|
684
|
+
|
685
|
+
def test_only_one_sheet
|
686
|
+
with_each_spreadsheet(:name=>'only_one_sheet') do |oo|
|
687
|
+
assert_equal 42, oo.cell('B',4)
|
688
|
+
assert_equal 43, oo.cell('C',4)
|
689
|
+
assert_equal 44, oo.cell('D',4)
|
690
|
+
oo.default_sheet = oo.sheets.first
|
691
|
+
assert_equal 42, oo.cell('B',4)
|
692
|
+
assert_equal 43, oo.cell('C',4)
|
693
|
+
assert_equal 44, oo.cell('D',4)
|
694
|
+
end
|
695
|
+
end
|
696
|
+
|
697
|
+
def test_excel_open_from_uri_and_zipped
|
698
|
+
if EXCEL
|
699
|
+
if ONLINE
|
700
|
+
begin
|
701
|
+
url = 'http://stiny-leonhard.de/bode-v1.xls.zip'
|
702
|
+
excel = Excel.new(url, :zip)
|
703
|
+
excel.default_sheet = excel.sheets.first
|
704
|
+
assert_equal 'ist "e" im Nenner von H(s)', excel.cell('b', 5)
|
705
|
+
end
|
706
|
+
end
|
707
|
+
end
|
708
|
+
end
|
709
|
+
|
710
|
+
def test_openoffice_open_from_uri_and_zipped
|
711
|
+
if OPENOFFICE
|
712
|
+
if ONLINE
|
713
|
+
begin
|
714
|
+
url = 'http://spazioinwind.libero.it/s2/rata.ods.zip'
|
715
|
+
sheet = Openoffice.new(url, :zip)
|
716
|
+
#has been changed: assert_equal 'ist "e" im Nenner von H(s)', sheet.cell('b', 5)
|
717
|
+
assert_in_delta 0.001, 505.14, sheet.cell('c', 33).to_f
|
718
|
+
end
|
719
|
+
end
|
720
|
+
end
|
721
|
+
end
|
722
|
+
|
723
|
+
def test_excel_zipped
|
724
|
+
if EXCEL
|
725
|
+
begin
|
726
|
+
oo = Excel.new(File.join(TESTDIR,"bode-v1.xls.zip"), :zip)
|
727
|
+
assert oo
|
728
|
+
assert_equal 'ist "e" im Nenner von H(s)', oo.cell('b', 5)
|
729
|
+
end
|
730
|
+
end
|
731
|
+
end
|
732
|
+
|
733
|
+
def test_openoffice_zipped
|
734
|
+
if OPENOFFICE
|
735
|
+
begin
|
736
|
+
oo = Openoffice.new(File.join(TESTDIR,"bode-v1.ods.zip"), :zip)
|
737
|
+
assert oo
|
738
|
+
assert_equal 'ist "e" im Nenner von H(s)', oo.cell('b', 5)
|
739
|
+
end
|
740
|
+
end
|
741
|
+
end
|
742
|
+
|
743
|
+
def test_bug_ric
|
744
|
+
with_each_spreadsheet(:name=>'ric', :format=>:openoffice) do |oo|
|
745
|
+
assert oo.empty?('A',1)
|
746
|
+
assert oo.empty?('B',1)
|
747
|
+
assert oo.empty?('C',1)
|
748
|
+
assert oo.empty?('D',1)
|
749
|
+
expected = 1
|
750
|
+
letter = 'e'
|
751
|
+
while letter <= 'u'
|
752
|
+
assert_equal expected, oo.cell(letter,1)
|
753
|
+
letter.succ!
|
754
|
+
expected += 1
|
755
|
+
end
|
756
|
+
assert_equal 'J', oo.cell('v',1)
|
757
|
+
assert_equal 'P', oo.cell('w',1)
|
758
|
+
assert_equal 'B', oo.cell('x',1)
|
759
|
+
assert_equal 'All', oo.cell('y',1)
|
760
|
+
assert_equal 0, oo.cell('a',2)
|
761
|
+
assert oo.empty?('b',2)
|
762
|
+
assert oo.empty?('c',2)
|
763
|
+
assert oo.empty?('d',2)
|
764
|
+
assert_equal 'B', oo.cell('e',2)
|
765
|
+
assert_equal 'B', oo.cell('f',2)
|
766
|
+
assert_equal 'B', oo.cell('g',2)
|
767
|
+
assert_equal 'B', oo.cell('h',2)
|
768
|
+
assert_equal 'B', oo.cell('i',2)
|
769
|
+
assert_equal 'B', oo.cell('j',2)
|
770
|
+
assert_equal 'B', oo.cell('k',2)
|
771
|
+
assert_equal 'B', oo.cell('l',2)
|
772
|
+
assert_equal 'B', oo.cell('m',2)
|
773
|
+
assert_equal 'B', oo.cell('n',2)
|
774
|
+
assert_equal 'B', oo.cell('o',2)
|
775
|
+
assert_equal 'B', oo.cell('p',2)
|
776
|
+
assert_equal 'B', oo.cell('q',2)
|
777
|
+
assert_equal 'B', oo.cell('r',2)
|
778
|
+
assert_equal 'B', oo.cell('s',2)
|
779
|
+
assert oo.empty?('t',2)
|
780
|
+
assert oo.empty?('u',2)
|
781
|
+
assert_equal 0 , oo.cell('v',2)
|
782
|
+
assert_equal 0 , oo.cell('w',2)
|
783
|
+
assert_equal 15 , oo.cell('x',2)
|
784
|
+
assert_equal 15 , oo.cell('y',2)
|
785
|
+
end
|
786
|
+
end
|
787
|
+
|
788
|
+
def test_mehrteilig
|
789
|
+
with_each_spreadsheet(:name=>'Bibelbund1', :format=>:openoffice) do |oo|
|
790
|
+
assert_equal "Tagebuch des Sekret\303\244rs. Letzte Tagung 15./16.11.75 Schweiz", oo.cell(45,'A')
|
791
|
+
end
|
792
|
+
#if EXCELX
|
793
|
+
# #Datei gibt es noch nicht
|
794
|
+
# oo = Excelx.new(File.join(TESTDIR,"Bibelbund1.xlsx"))
|
795
|
+
# oo.default_sheet = oo.sheets.first
|
796
|
+
# assert_equal "Tagebuch des Sekret\303\244rs. Letzte Tagung 15./16.11.75 Schweiz", oo.cell(45,'A')
|
797
|
+
#end
|
798
|
+
end
|
799
|
+
|
800
|
+
def tempdir
|
801
|
+
Dir::tmpdir
|
802
|
+
end
|
803
|
+
|
804
|
+
# "/tmp/xxxx" darf man unter Windows nicht verwenden, weil das nicht erkannt
|
805
|
+
# wird.
|
806
|
+
# Besser: Methode um temporaeres Dir. portabel zu bestimmen
|
807
|
+
def test_huge_document_to_csv
|
808
|
+
if LONG_RUN
|
809
|
+
with_each_spreadsheet(:name=>'Bibelbund', :format=>[:openoffice,
|
810
|
+
:excel,
|
811
|
+
:excelx
|
812
|
+
# Google hier nicht, weil Google-Spreadsheets nicht so gross werden
|
813
|
+
# duerfen
|
814
|
+
]) do |oo|
|
815
|
+
assert_nothing_raised(Timeout::Error) {
|
816
|
+
Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
|
817
|
+
File.delete_if_exist(File.join(tempdir,"Bibelbund.csv"))
|
818
|
+
assert_equal "Tagebuch des Sekret\303\244rs. Letzte Tagung 15./16.11.75 Schweiz", oo.cell(45,'A')
|
819
|
+
assert_equal "Tagebuch des Sekret\303\244rs. Nachrichten aus Chile", oo.cell(46,'A')
|
820
|
+
assert_equal "Tagebuch aus Chile Juli 1977", oo.cell(55,'A')
|
821
|
+
assert oo.to_csv(File.join(tempdir,"Bibelbund.csv"))
|
822
|
+
assert File.exists?(File.join(tempdir,"Bibelbund.csv"))
|
823
|
+
#if running_windows?
|
824
|
+
# to do
|
825
|
+
# "diff is not available under windows"
|
826
|
+
# end
|
827
|
+
#else
|
828
|
+
# assert_equal "", `diff test/Bibelbund.csv /tmp/Bibelbund.csv`, "error in class #{oo.class}"
|
829
|
+
# assert_equal "", `diff test/Bibelbund.csv #{File.join(tempdir,"Bibelbund.csv")}`, "error in class #{oo.class}"
|
830
|
+
assert_equal "",
|
831
|
+
diff("test/Bibelbund.csv","#{File.join(tempdir,"Bibelbund.csv")}"),
|
832
|
+
"error in class #{oo.class}"
|
833
|
+
#end
|
834
|
+
end
|
835
|
+
}
|
836
|
+
end
|
837
|
+
end
|
838
|
+
end
|
839
|
+
|
840
|
+
def test_bug_quotes_excelx
|
841
|
+
if LONG_RUN
|
842
|
+
with_each_spreadsheet(:name=>'Bibelbund', :format=>[:openoffice,
|
843
|
+
:excel,
|
844
|
+
:excelx]) do |oo|
|
845
|
+
oo.default_sheet = oo.sheets.first
|
846
|
+
assert_equal 'Einflüsse der neuen Theologie in "de gereformeerde Kerken van Nederland"',
|
847
|
+
oo.cell('a',76)
|
848
|
+
dummy = oo.to_csv("csv#{$$}")
|
849
|
+
assert_equal 'Einflüsse der neuen Theologie in "de gereformeerde Kerken van Nederland"',
|
850
|
+
oo.cell('a',78)
|
851
|
+
File.delete_if_exist("csv#{$$}")
|
852
|
+
end
|
853
|
+
end
|
854
|
+
end
|
855
|
+
|
856
|
+
def test_to_csv
|
857
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
858
|
+
master = "#{TESTDIR}/numbers1.csv"
|
859
|
+
File.delete_if_exist(File.join(tempdir,"numbers1.csv"))
|
860
|
+
assert oo.to_csv(File.join(tempdir,"numbers1.csv"),oo.sheets.first)
|
861
|
+
assert(File.exists?(File.join(tempdir,"numbers1.csv")), "Datei #{tempdir}/numbers1.csv existiert nicht")
|
862
|
+
if running_windows?
|
863
|
+
warn "no 'diff' in windows"
|
864
|
+
else
|
865
|
+
assert_equal "", `diff #{master} #{File.join(tempdir,"numbers1.csv")}`
|
866
|
+
assert oo.to_csv(File.join(tempdir,"numbers1.csv"))
|
867
|
+
assert File.exists?(File.join(tempdir,"numbers1.csv"))
|
868
|
+
assert_equal "", `diff #{master} #{File.join(tempdir,"numbers1.csv")}`
|
869
|
+
end
|
870
|
+
end
|
871
|
+
end
|
872
|
+
|
873
|
+
def test_bug_mehrere_datum
|
874
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
875
|
+
oo.default_sheet = 'Sheet5'
|
876
|
+
assert_equal :date, oo.celltype('A',4)
|
877
|
+
assert_equal :date, oo.celltype('B',4)
|
878
|
+
assert_equal :date, oo.celltype('C',4)
|
879
|
+
assert_equal :date, oo.celltype('D',4)
|
880
|
+
assert_equal :date, oo.celltype('E',4)
|
881
|
+
assert_equal Date.new(2007,11,21), oo.cell('A',4)
|
882
|
+
assert_equal Date.new(2007,11,21), oo.cell('B',4)
|
883
|
+
assert_equal Date.new(2007,11,21), oo.cell('C',4)
|
884
|
+
assert_equal Date.new(2007,11,21), oo.cell('D',4)
|
885
|
+
assert_equal Date.new(2007,11,21), oo.cell('E',4)
|
886
|
+
assert_equal :float, oo.celltype('A',5)
|
887
|
+
assert_equal :float, oo.celltype('B',5)
|
888
|
+
assert_equal :float, oo.celltype('C',5)
|
889
|
+
assert_equal :float, oo.celltype('D',5)
|
890
|
+
assert_equal :float, oo.celltype('E',5)
|
891
|
+
assert_equal 42, oo.cell('A',5)
|
892
|
+
assert_equal 42, oo.cell('B',5)
|
893
|
+
assert_equal 42, oo.cell('C',5)
|
894
|
+
assert_equal 42, oo.cell('D',5)
|
895
|
+
assert_equal 42, oo.cell('E',5)
|
896
|
+
assert_equal :string, oo.celltype('A',6)
|
897
|
+
assert_equal :string, oo.celltype('B',6)
|
898
|
+
assert_equal :string, oo.celltype('C',6)
|
899
|
+
assert_equal :string, oo.celltype('D',6)
|
900
|
+
assert_equal :string, oo.celltype('E',6)
|
901
|
+
assert_equal "ABC", oo.cell('A',6)
|
902
|
+
assert_equal "ABC", oo.cell('B',6)
|
903
|
+
assert_equal "ABC", oo.cell('C',6)
|
904
|
+
assert_equal "ABC", oo.cell('D',6)
|
905
|
+
assert_equal "ABC", oo.cell('E',6)
|
906
|
+
end
|
907
|
+
end
|
908
|
+
|
909
|
+
def test_multiple_sheets
|
910
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
911
|
+
2.times do
|
912
|
+
oo.default_sheet = "Tabelle1"
|
913
|
+
assert_equal 1, oo.cell(1,1)
|
914
|
+
assert_equal 1, oo.cell(1,1,"Tabelle1")
|
915
|
+
assert_equal "I am sheet 2", oo.cell('C',5,"Name of Sheet 2")
|
916
|
+
sheetname = 'Sheet5'
|
917
|
+
assert_equal :date, oo.celltype('A',4,sheetname)
|
918
|
+
assert_equal :date, oo.celltype('B',4,sheetname)
|
919
|
+
assert_equal :date, oo.celltype('C',4,sheetname)
|
920
|
+
assert_equal :date, oo.celltype('D',4,sheetname)
|
921
|
+
assert_equal :date, oo.celltype('E',4,sheetname)
|
922
|
+
assert_equal Date.new(2007,11,21), oo.cell('A',4,sheetname)
|
923
|
+
assert_equal Date.new(2007,11,21), oo.cell('B',4,sheetname)
|
924
|
+
assert_equal Date.new(2007,11,21), oo.cell('C',4,sheetname)
|
925
|
+
assert_equal Date.new(2007,11,21), oo.cell('D',4,sheetname)
|
926
|
+
assert_equal Date.new(2007,11,21), oo.cell('E',4,sheetname)
|
927
|
+
assert_equal :float, oo.celltype('A',5,sheetname)
|
928
|
+
assert_equal :float, oo.celltype('B',5,sheetname)
|
929
|
+
assert_equal :float, oo.celltype('C',5,sheetname)
|
930
|
+
assert_equal :float, oo.celltype('D',5,sheetname)
|
931
|
+
assert_equal :float, oo.celltype('E',5,sheetname)
|
932
|
+
assert_equal 42, oo.cell('A',5,sheetname)
|
933
|
+
assert_equal 42, oo.cell('B',5,sheetname)
|
934
|
+
assert_equal 42, oo.cell('C',5,sheetname)
|
935
|
+
assert_equal 42, oo.cell('D',5,sheetname)
|
936
|
+
assert_equal 42, oo.cell('E',5,sheetname)
|
937
|
+
assert_equal :string, oo.celltype('A',6,sheetname)
|
938
|
+
assert_equal :string, oo.celltype('B',6,sheetname)
|
939
|
+
assert_equal :string, oo.celltype('C',6,sheetname)
|
940
|
+
assert_equal :string, oo.celltype('D',6,sheetname)
|
941
|
+
assert_equal :string, oo.celltype('E',6,sheetname)
|
942
|
+
assert_equal "ABC", oo.cell('A',6,sheetname)
|
943
|
+
assert_equal "ABC", oo.cell('B',6,sheetname)
|
944
|
+
assert_equal "ABC", oo.cell('C',6,sheetname)
|
945
|
+
assert_equal "ABC", oo.cell('D',6,sheetname)
|
946
|
+
assert_equal "ABC", oo.cell('E',6,sheetname)
|
947
|
+
oo.reload
|
948
|
+
end
|
949
|
+
end
|
950
|
+
end
|
951
|
+
|
952
|
+
|
953
|
+
def test_bug_empty_sheet
|
954
|
+
with_each_spreadsheet(:name=>'formula', :format=>[:openoffice, :excelx]) do |oo|
|
955
|
+
oo.default_sheet = 'Sheet3' # is an empty sheet
|
956
|
+
assert_nothing_raised() { oo.to_csv(File.join(tempdir,"emptysheet.csv")) }
|
957
|
+
assert_equal "", `cat #{File.join(tempdir,"emptysheet.csv")}`
|
958
|
+
end
|
959
|
+
end
|
960
|
+
|
961
|
+
def test_find_by_row_huge_document
|
962
|
+
if LONG_RUN
|
963
|
+
with_each_spreadsheet(:name=>'Bibelbund', :format=>[:openoffice,
|
964
|
+
:excel,
|
965
|
+
:excelx]) do |oo|
|
966
|
+
Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
|
967
|
+
oo.default_sheet = oo.sheets.first
|
968
|
+
rec = oo.find 20
|
969
|
+
assert rec
|
970
|
+
# assert_equal "Brief aus dem Sekretariat", rec[0]
|
971
|
+
#p rec
|
972
|
+
assert_equal "Brief aus dem Sekretariat", rec[0]['TITEL']
|
973
|
+
rec = oo.find 22
|
974
|
+
assert rec
|
975
|
+
# assert_equal "Brief aus dem Skretariat. Tagung in Amberg/Opf.",rec[0]
|
976
|
+
assert_equal "Brief aus dem Skretariat. Tagung in Amberg/Opf.",rec[0]['TITEL']
|
977
|
+
end
|
978
|
+
end
|
979
|
+
end
|
980
|
+
end
|
981
|
+
|
982
|
+
def test_find_by_row
|
983
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
984
|
+
oo.header_line = nil
|
985
|
+
rec = oo.find 16
|
986
|
+
assert rec
|
987
|
+
assert_nil oo.header_line
|
988
|
+
# keine Headerlines in diesem Beispiel definiert
|
989
|
+
assert_equal "einundvierzig", rec[0]
|
990
|
+
#assert_equal false, rec
|
991
|
+
rec = oo.find 15
|
992
|
+
assert rec
|
993
|
+
assert_equal 41,rec[0]
|
994
|
+
end
|
995
|
+
end
|
996
|
+
|
997
|
+
def test_find_by_conditions
|
998
|
+
if LONG_RUN
|
999
|
+
with_each_spreadsheet(:name=>'Bibelbund', :format=>[:openoffice,
|
1000
|
+
:excel,
|
1001
|
+
:excelx]) do |oo|
|
1002
|
+
assert_nothing_raised(Timeout::Error) {
|
1003
|
+
Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
|
1004
|
+
#-----------------------------------------------------------------
|
1005
|
+
zeilen = oo.find(:all, :conditions => {
|
1006
|
+
'TITEL' => 'Brief aus dem Sekretariat'
|
1007
|
+
}
|
1008
|
+
)
|
1009
|
+
assert_equal 2, zeilen.size
|
1010
|
+
assert_equal [{"VERFASSER"=>"Almassy, Annelene von",
|
1011
|
+
"INTERNET"=>nil,
|
1012
|
+
"SEITE"=>316.0,
|
1013
|
+
"KENNUNG"=>"Aus dem Bibelbund",
|
1014
|
+
"OBJEKT"=>"Bibel+Gem",
|
1015
|
+
"PC"=>"#C:\\Bibelbund\\reprint\\BuG1982-3.pdf#",
|
1016
|
+
"NUMMER"=>"1982-3",
|
1017
|
+
"TITEL"=>"Brief aus dem Sekretariat"},
|
1018
|
+
{"VERFASSER"=>"Almassy, Annelene von",
|
1019
|
+
"INTERNET"=>nil,
|
1020
|
+
"SEITE"=>222.0,
|
1021
|
+
"KENNUNG"=>"Aus dem Bibelbund",
|
1022
|
+
"OBJEKT"=>"Bibel+Gem",
|
1023
|
+
"PC"=>"#C:\\Bibelbund\\reprint\\BuG1983-2.pdf#",
|
1024
|
+
"NUMMER"=>"1983-2",
|
1025
|
+
"TITEL"=>"Brief aus dem Sekretariat"}] , zeilen
|
1026
|
+
|
1027
|
+
#----------------------------------------------------------
|
1028
|
+
zeilen = oo.find(:all,
|
1029
|
+
:conditions => { 'VERFASSER' => 'Almassy, Annelene von' }
|
1030
|
+
)
|
1031
|
+
assert_equal 13, zeilen.size
|
1032
|
+
#----------------------------------------------------------
|
1033
|
+
zeilen = oo.find(:all, :conditions => {
|
1034
|
+
'TITEL' => 'Brief aus dem Sekretariat',
|
1035
|
+
'VERFASSER' => 'Almassy, Annelene von',
|
1036
|
+
}
|
1037
|
+
)
|
1038
|
+
assert_equal 2, zeilen.size
|
1039
|
+
assert_equal [{"VERFASSER"=>"Almassy, Annelene von",
|
1040
|
+
"INTERNET"=>nil,
|
1041
|
+
"SEITE"=>316.0,
|
1042
|
+
"KENNUNG"=>"Aus dem Bibelbund",
|
1043
|
+
"OBJEKT"=>"Bibel+Gem",
|
1044
|
+
"PC"=>"#C:\\Bibelbund\\reprint\\BuG1982-3.pdf#",
|
1045
|
+
"NUMMER"=>"1982-3",
|
1046
|
+
"TITEL"=>"Brief aus dem Sekretariat"},
|
1047
|
+
{"VERFASSER"=>"Almassy, Annelene von",
|
1048
|
+
"INTERNET"=>nil,
|
1049
|
+
"SEITE"=>222.0,
|
1050
|
+
"KENNUNG"=>"Aus dem Bibelbund",
|
1051
|
+
"OBJEKT"=>"Bibel+Gem",
|
1052
|
+
"PC"=>"#C:\\Bibelbund\\reprint\\BuG1983-2.pdf#",
|
1053
|
+
"NUMMER"=>"1983-2",
|
1054
|
+
"TITEL"=>"Brief aus dem Sekretariat"}] , zeilen
|
1055
|
+
|
1056
|
+
# Result as an array
|
1057
|
+
zeilen = oo.find(:all,
|
1058
|
+
:conditions => {
|
1059
|
+
'TITEL' => 'Brief aus dem Sekretariat',
|
1060
|
+
'VERFASSER' => 'Almassy, Annelene von',
|
1061
|
+
}, :array => true)
|
1062
|
+
assert_equal 2, zeilen.size
|
1063
|
+
assert_equal [
|
1064
|
+
[
|
1065
|
+
"Brief aus dem Sekretariat",
|
1066
|
+
"Almassy, Annelene von",
|
1067
|
+
"Bibel+Gem",
|
1068
|
+
"1982-3",
|
1069
|
+
316.0,
|
1070
|
+
nil,
|
1071
|
+
"#C:\\Bibelbund\\reprint\\BuG1982-3.pdf#",
|
1072
|
+
"Aus dem Bibelbund",
|
1073
|
+
],
|
1074
|
+
[
|
1075
|
+
"Brief aus dem Sekretariat",
|
1076
|
+
"Almassy, Annelene von",
|
1077
|
+
"Bibel+Gem",
|
1078
|
+
"1983-2",
|
1079
|
+
222.0,
|
1080
|
+
nil,
|
1081
|
+
"#C:\\Bibelbund\\reprint\\BuG1983-2.pdf#",
|
1082
|
+
"Aus dem Bibelbund",
|
1083
|
+
]] , zeilen
|
1084
|
+
end # Timeout
|
1085
|
+
} # nothing_raised
|
1086
|
+
end
|
1087
|
+
end
|
1088
|
+
end
|
1089
|
+
|
1090
|
+
|
1091
|
+
#TODO: temporaerer Test
|
1092
|
+
def test_seiten_als_date
|
1093
|
+
if LONG_RUN
|
1094
|
+
with_each_spreadsheet(:name=>'Bibelbund', :format=>:excelx) do |oo|
|
1095
|
+
assert_equal 'Bericht aus dem Sekretariat', oo.cell(13,1)
|
1096
|
+
assert_equal '1981-4', oo.cell(13,'D')
|
1097
|
+
assert_equal String, oo.excelx_type(13,'E')[1].class
|
1098
|
+
assert_equal [:numeric_or_formula,"General"], oo.excelx_type(13,'E')
|
1099
|
+
assert_equal '428', oo.excelx_value(13,'E')
|
1100
|
+
assert_equal 428.0, oo.cell(13,'E')
|
1101
|
+
end
|
1102
|
+
end
|
1103
|
+
end
|
1104
|
+
|
1105
|
+
def test_column
|
1106
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
1107
|
+
expected = [1.0,5.0,nil,10.0,Date.new(1961,11,21),'tata',nil,nil,nil,nil,'thisisa11',41.0,nil,nil,41.0,'einundvierzig',nil,Date.new(2007,5,31)]
|
1108
|
+
assert_equal expected, oo.column(1)
|
1109
|
+
assert_equal expected, oo.column('a')
|
1110
|
+
end
|
1111
|
+
end
|
1112
|
+
|
1113
|
+
def test_column_huge_document
|
1114
|
+
if LONG_RUN
|
1115
|
+
with_each_spreadsheet(:name=>'Bibelbund', :format=>[:openoffice,
|
1116
|
+
:excel,
|
1117
|
+
:excelx]) do |oo|
|
1118
|
+
assert_nothing_raised(Timeout::Error) {
|
1119
|
+
Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
|
1120
|
+
oo.default_sheet = oo.sheets.first
|
1121
|
+
assert_equal 3735, oo.column('a').size
|
1122
|
+
#assert_equal 499, oo.column('a').size
|
1123
|
+
end
|
1124
|
+
}
|
1125
|
+
end
|
1126
|
+
end
|
1127
|
+
end
|
1128
|
+
|
1129
|
+
def test_simple_spreadsheet_find_by_condition
|
1130
|
+
with_each_spreadsheet(:name=>'simple_spreadsheet') do |oo|
|
1131
|
+
oo.header_line = 3
|
1132
|
+
# oo.date_format = '%m/%d/%Y' if oo.class == Google
|
1133
|
+
erg = oo.find(:all, :conditions => {'Comment' => 'Task 1'})
|
1134
|
+
assert_equal Date.new(2007,05,07), erg[1]['Date']
|
1135
|
+
assert_equal 10.75 , erg[1]['Start time']
|
1136
|
+
assert_equal 12.50 , erg[1]['End time']
|
1137
|
+
assert_equal 0 , erg[1]['Pause']
|
1138
|
+
assert_equal 1.75 , erg[1]['Sum'] unless oo.class == Excel
|
1139
|
+
assert_equal "Task 1" , erg[1]['Comment']
|
1140
|
+
end
|
1141
|
+
end
|
1142
|
+
|
1143
|
+
# Ruby-spreadsheet now allows us to at least give the current value
|
1144
|
+
# from a cell with a formula (no possible with parseexcel)
|
1145
|
+
def test_bug_false_borders_with_formulas
|
1146
|
+
with_each_spreadsheet(:name=>'false_encoding', :format=>:excel) do |oo|
|
1147
|
+
assert_equal 1, oo.first_row
|
1148
|
+
assert_equal 3, oo.last_row
|
1149
|
+
assert_equal 1, oo.first_column
|
1150
|
+
assert_equal 4, oo.last_column
|
1151
|
+
end
|
1152
|
+
end
|
1153
|
+
|
1154
|
+
# We'ce added minimal formula support so we can now read these
|
1155
|
+
# though not sure how the spreadsheet reports older values....
|
1156
|
+
def test_fe
|
1157
|
+
with_each_spreadsheet(:name=>'false_encoding', :format=>:excel) do |oo|
|
1158
|
+
assert_equal Date.new(2007,11,1), oo.cell('a',1)
|
1159
|
+
#DOES NOT WORK IN EXCEL FILES: assert_equal true, oo.formula?('a',1)
|
1160
|
+
#DOES NOT WORK IN EXCEL FILES: assert_equal '=TODAY()', oo.formula('a',1)
|
1161
|
+
|
1162
|
+
assert_equal Date.new(2008,2,9), oo.cell('B',1)
|
1163
|
+
#DOES NOT WORK IN EXCEL FILES: assert_equal true, oo.formula?('B',1)
|
1164
|
+
#DOES NOT WORK IN EXCEL FILES: assert_equal "=A1+100", oo.formula('B',1)
|
1165
|
+
|
1166
|
+
assert_kind_of DateTime, oo.cell('C',1)
|
1167
|
+
#DOES NOT WORK IN EXCEL FILES: assert_equal true, oo.formula?('C',1)
|
1168
|
+
#DOES NOT WORK IN EXCEL FILES: assert_equal "=C1", oo.formula('C',1)
|
1169
|
+
|
1170
|
+
assert_equal 'H1', oo.cell('A',2)
|
1171
|
+
assert_equal 'H2', oo.cell('B',2)
|
1172
|
+
assert_equal 'H3', oo.cell('C',2)
|
1173
|
+
assert_equal 'H4', oo.cell('D',2)
|
1174
|
+
assert_equal 'R1', oo.cell('A',3)
|
1175
|
+
assert_equal 'R2', oo.cell('B',3)
|
1176
|
+
assert_equal 'R3', oo.cell('C',3)
|
1177
|
+
assert_equal 'R4', oo.cell('D',3)
|
1178
|
+
end
|
1179
|
+
end
|
1180
|
+
|
1181
|
+
def test_excel_does_not_support_formulas
|
1182
|
+
with_each_spreadsheet(:name=>'false_encoding', :format=>:excel) do |oo|
|
1183
|
+
assert_raise(RuntimeError) { void = oo.formula('a',1) }
|
1184
|
+
assert_raise(RuntimeError) { void = oo.formula?('a',1) }
|
1185
|
+
assert_raise(RuntimeError) { void = oo.formulas(oo.sheets.first) }
|
1186
|
+
end
|
1187
|
+
end
|
1188
|
+
|
1189
|
+
def get_extension(oo)
|
1190
|
+
case oo
|
1191
|
+
when Openoffice
|
1192
|
+
".ods"
|
1193
|
+
when Excel
|
1194
|
+
".xls"
|
1195
|
+
when Excelx
|
1196
|
+
".xlsx"
|
1197
|
+
when Google
|
1198
|
+
""
|
1199
|
+
end
|
1200
|
+
end
|
1201
|
+
|
1202
|
+
def test_info
|
1203
|
+
expected_templ = "File: numbers1%s\n"+
|
1204
|
+
"Number of sheets: 5\n"+
|
1205
|
+
"Sheets: Tabelle1, Name of Sheet 2, Sheet3, Sheet4, Sheet5\n"+
|
1206
|
+
"Sheet 1:\n"+
|
1207
|
+
" First row: 1\n"+
|
1208
|
+
" Last row: 18\n"+
|
1209
|
+
" First column: A\n"+
|
1210
|
+
" Last column: G\n"+
|
1211
|
+
"Sheet 2:\n"+
|
1212
|
+
" First row: 5\n"+
|
1213
|
+
" Last row: 14\n"+
|
1214
|
+
" First column: B\n"+
|
1215
|
+
" Last column: E\n"+
|
1216
|
+
"Sheet 3:\n"+
|
1217
|
+
" First row: 1\n"+
|
1218
|
+
" Last row: 1\n"+
|
1219
|
+
" First column: A\n"+
|
1220
|
+
" Last column: BA\n"+
|
1221
|
+
"Sheet 4:\n"+
|
1222
|
+
" First row: 1\n"+
|
1223
|
+
" Last row: 1\n"+
|
1224
|
+
" First column: A\n"+
|
1225
|
+
" Last column: E\n"+
|
1226
|
+
"Sheet 5:\n"+
|
1227
|
+
" First row: 1\n"+
|
1228
|
+
" Last row: 6\n"+
|
1229
|
+
" First column: A\n"+
|
1230
|
+
" Last column: E"
|
1231
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
1232
|
+
ext = get_extension(oo)
|
1233
|
+
expected = sprintf(expected_templ,ext)
|
1234
|
+
begin
|
1235
|
+
if oo.class == Google
|
1236
|
+
assert_equal expected.gsub(/numbers1/,key_of("numbers1")), oo.info
|
1237
|
+
else
|
1238
|
+
assert_equal expected, oo.info
|
1239
|
+
end
|
1240
|
+
rescue NameError
|
1241
|
+
#
|
1242
|
+
end
|
1243
|
+
end
|
1244
|
+
end
|
1245
|
+
|
1246
|
+
def test_bug_excel_numbers1_sheet5_last_row
|
1247
|
+
with_each_spreadsheet(:name=>'numbers1', :format=>:excel) do |oo|
|
1248
|
+
oo.default_sheet = "Tabelle1"
|
1249
|
+
assert_equal 1, oo.first_row
|
1250
|
+
assert_equal 18, oo.last_row
|
1251
|
+
assert_equal Openoffice.letter_to_number('A'), oo.first_column
|
1252
|
+
assert_equal Openoffice.letter_to_number('G'), oo.last_column
|
1253
|
+
oo.default_sheet = "Name of Sheet 2"
|
1254
|
+
assert_equal 5, oo.first_row
|
1255
|
+
assert_equal 14, oo.last_row
|
1256
|
+
assert_equal Openoffice.letter_to_number('B'), oo.first_column
|
1257
|
+
assert_equal Openoffice.letter_to_number('E'), oo.last_column
|
1258
|
+
oo.default_sheet = "Sheet3"
|
1259
|
+
assert_equal 1, oo.first_row
|
1260
|
+
assert_equal 1, oo.last_row
|
1261
|
+
assert_equal Openoffice.letter_to_number('A'), oo.first_column
|
1262
|
+
assert_equal Openoffice.letter_to_number('BA'), oo.last_column
|
1263
|
+
oo.default_sheet = "Sheet4"
|
1264
|
+
assert_equal 1, oo.first_row
|
1265
|
+
assert_equal 1, oo.last_row
|
1266
|
+
assert_equal Openoffice.letter_to_number('A'), oo.first_column
|
1267
|
+
assert_equal Openoffice.letter_to_number('E'), oo.last_column
|
1268
|
+
oo.default_sheet = "Sheet5"
|
1269
|
+
assert_equal 1, oo.first_row
|
1270
|
+
assert_equal 6, oo.last_row
|
1271
|
+
assert_equal Openoffice.letter_to_number('A'), oo.first_column
|
1272
|
+
assert_equal Openoffice.letter_to_number('E'), oo.last_column
|
1273
|
+
end
|
1274
|
+
end
|
1275
|
+
|
1276
|
+
def test_should_raise_file_not_found_error
|
1277
|
+
if OPENOFFICE
|
1278
|
+
assert_raise(IOError) {
|
1279
|
+
oo = Openoffice.new(File.join('testnichtvorhanden','Bibelbund.ods'))
|
1280
|
+
}
|
1281
|
+
end
|
1282
|
+
if EXCEL
|
1283
|
+
assert_raise(IOError) {
|
1284
|
+
oo = Excel.new(File.join('testnichtvorhanden','Bibelbund.xls'))
|
1285
|
+
}
|
1286
|
+
end
|
1287
|
+
if EXCELX
|
1288
|
+
assert_raise(IOError) {
|
1289
|
+
oo = Excelx.new(File.join('testnichtvorhanden','Bibelbund.xlsx'))
|
1290
|
+
}
|
1291
|
+
end
|
1292
|
+
if GOOGLE
|
1293
|
+
# assert_raise(Net::HTTPServerException) {
|
1294
|
+
# oo = Google.new(key_of('testnichtvorhanden'+'Bibelbund.ods'))
|
1295
|
+
# oo = Google.new('testnichtvorhanden')
|
1296
|
+
# }
|
1297
|
+
end
|
1298
|
+
end
|
1299
|
+
|
1300
|
+
def test_write_google
|
1301
|
+
# write.me: http://spreadsheets.google.com/ccc?key=ptu6bbahNZpY0N0RrxQbWdw&hl=en_GB
|
1302
|
+
with_each_spreadsheet(:name=>'write.me', :format=>:google) do |oo|
|
1303
|
+
oo.default_sheet = oo.sheets.first
|
1304
|
+
oo.set_value(1,1,"hello from the tests")
|
1305
|
+
assert_equal "hello from the tests", oo.cell(1,1)
|
1306
|
+
oo.set_value(1,1, 1.0)
|
1307
|
+
assert_equal 1.0, oo.cell(1,1)
|
1308
|
+
end
|
1309
|
+
end
|
1310
|
+
|
1311
|
+
def test_bug_set_value_with_more_than_one_sheet_google
|
1312
|
+
# write.me: http://spreadsheets.google.com/ccc?key=ptu6bbahNZpY0N0RrxQbWdw&hl=en_GB
|
1313
|
+
after Date.new(2011,6,19) do
|
1314
|
+
with_each_spreadsheet(:name=>'write.me', :format=>:google) do |oo|
|
1315
|
+
content1 = 'AAA'
|
1316
|
+
content2 = 'BBB'
|
1317
|
+
oo.default_sheet = oo.sheets.first
|
1318
|
+
oo.set_value(1,1,content1)
|
1319
|
+
oo.default_sheet = oo.sheets[1]
|
1320
|
+
oo.set_value(1,1,content2) # in the second sheet
|
1321
|
+
oo.default_sheet = oo.sheets.first
|
1322
|
+
assert_equal content1, oo.cell(1,1)
|
1323
|
+
oo.default_sheet = oo.sheets[1]
|
1324
|
+
assert_equal content2, oo.cell(1,1)
|
1325
|
+
end
|
1326
|
+
end
|
1327
|
+
end
|
1328
|
+
|
1329
|
+
def test_set_value_with_sheet_argument_google
|
1330
|
+
with_each_spreadsheet(:name=>'write.me', :format=>:google) do |oo|
|
1331
|
+
random_row = rand(10)+1
|
1332
|
+
random_column = rand(10)+1
|
1333
|
+
content1 = 'ABC'
|
1334
|
+
content2 = 'DEF'
|
1335
|
+
oo.set_value(random_row,random_column,content1,oo.sheets.first)
|
1336
|
+
oo.set_value(random_row,random_column,content2,oo.sheets[1])
|
1337
|
+
assert_equal content1, oo.cell(random_row,random_column,oo.sheets.first)
|
1338
|
+
assert_equal content2, oo.cell(random_row,random_column,oo.sheets[1])
|
1339
|
+
end
|
1340
|
+
end
|
1341
|
+
|
1342
|
+
def test_set_value_for_non_existing_sheet_google
|
1343
|
+
with_each_spreadsheet(:name=>'ptu6bbahNZpY0N0RrxQbWdw', :format=>:google) do |oo|
|
1344
|
+
assert_raise(RangeError) { oo.set_value(1,1,"dummy","no_sheet") }
|
1345
|
+
end
|
1346
|
+
end
|
1347
|
+
|
1348
|
+
def test_bug_bbu
|
1349
|
+
with_each_spreadsheet(:name=>'bbu', :format=>[:openoffice, :excelx, :excel]) do |oo|
|
1350
|
+
assert_nothing_raised() {
|
1351
|
+
assert_equal "File: bbu#{get_extension(oo)}
|
1352
|
+
Number of sheets: 3
|
1353
|
+
Sheets: 2007_12, Tabelle2, Tabelle3
|
1354
|
+
Sheet 1:
|
1355
|
+
First row: 1
|
1356
|
+
Last row: 4
|
1357
|
+
First column: A
|
1358
|
+
Last column: F
|
1359
|
+
Sheet 2:
|
1360
|
+
- empty -
|
1361
|
+
Sheet 3:
|
1362
|
+
- empty -", oo.info
|
1363
|
+
}
|
1364
|
+
|
1365
|
+
oo.default_sheet = oo.sheets[1] # empty sheet
|
1366
|
+
assert_nil oo.first_row
|
1367
|
+
assert_nil oo.last_row
|
1368
|
+
assert_nil oo.first_column
|
1369
|
+
assert_nil oo.last_column
|
1370
|
+
end
|
1371
|
+
end
|
1372
|
+
|
1373
|
+
|
1374
|
+
def test_bug_time_nil
|
1375
|
+
with_each_spreadsheet(:name=>'time-test') do |oo|
|
1376
|
+
assert_equal 12*3600+13*60+14, oo.cell('B',1) # 12:13:14 (secs since midnight)
|
1377
|
+
assert_equal :time, oo.celltype('B',1)
|
1378
|
+
assert_equal 15*3600+16*60, oo.cell('C',1) # 15:16 (secs since midnight)
|
1379
|
+
assert_equal :time, oo.celltype('C',1)
|
1380
|
+
assert_equal 23*3600, oo.cell('D',1) # 23:00 (secs since midnight)
|
1381
|
+
assert_equal :time, oo.celltype('D',1)
|
1382
|
+
end
|
1383
|
+
end
|
1384
|
+
|
1385
|
+
def test_date_time_to_csv
|
1386
|
+
with_each_spreadsheet(:name=>'time-test') do |oo|
|
1387
|
+
begin
|
1388
|
+
csv_output = File.join(tempdir,'time_test.csv')
|
1389
|
+
assert oo.to_csv(csv_output)
|
1390
|
+
assert File.exists?(csv_output)
|
1391
|
+
assert_equal "", `diff --strip-trailing-cr #{TESTDIR}/time-test.csv #{csv_output}`
|
1392
|
+
# --strip-trailing-cr is needed because the test-file use 0A and
|
1393
|
+
# the test on an windows box generates 0D 0A as line endings
|
1394
|
+
ensure
|
1395
|
+
File.delete_if_exist(csv_output)
|
1396
|
+
end
|
1397
|
+
end
|
1398
|
+
end
|
1399
|
+
|
1400
|
+
def test_date_time_yaml
|
1401
|
+
with_each_spreadsheet(:name=>'time-test') do |oo|
|
1402
|
+
expected =
|
1403
|
+
"--- \ncell_1_1: \n row: 1 \n col: 1 \n celltype: string \n value: Mittags: \ncell_1_2: \n row: 1 \n col: 2 \n celltype: time \n value: 12:13:14 \ncell_1_3: \n row: 1 \n col: 3 \n celltype: time \n value: 15:16:00 \ncell_1_4: \n row: 1 \n col: 4 \n celltype: time \n value: 23:00:00 \ncell_2_1: \n row: 2 \n col: 1 \n celltype: date \n value: 2007-11-21 \n"
|
1404
|
+
assert_equal expected, oo.to_yaml
|
1405
|
+
end
|
1406
|
+
end
|
1407
|
+
|
1408
|
+
def test_no_remaining_tmp_files_openoffice
|
1409
|
+
if OPENOFFICE
|
1410
|
+
prev = Dir.glob(TMP_PREFIX)
|
1411
|
+
assert_raise(Zip::ZipError) { #TODO: besseres Fehlerkriterium bei
|
1412
|
+
# oo = Openoffice.new(File.join(TESTDIR,"no_spreadsheet_file.txt"))
|
1413
|
+
# es soll absichtlich ein Abbruch provoziert werden, deshalb :ignore
|
1414
|
+
oo = Openoffice.new(File.join(TESTDIR,"no_spreadsheet_file.txt"),
|
1415
|
+
false,
|
1416
|
+
:ignore)
|
1417
|
+
}
|
1418
|
+
now = Dir.glob(TMP_PREFIX)
|
1419
|
+
assert (now-prev).empty?, "temporay directory was not deleted"
|
1420
|
+
end
|
1421
|
+
end
|
1422
|
+
|
1423
|
+
def test_no_remaining_tmp_files_excel
|
1424
|
+
if EXCEL
|
1425
|
+
prev = Dir.glob(TMP_PREFIX)
|
1426
|
+
assert_raise(Ole::Storage::FormatError) {
|
1427
|
+
oo = Excel.new(File.join(TESTDIR,"no_spreadsheet_file.txt"),
|
1428
|
+
false,
|
1429
|
+
:ignore)
|
1430
|
+
}
|
1431
|
+
now = Dir.glob(TMP_PREFIX)
|
1432
|
+
assert (now-prev).empty?, "temporary directory not removed"
|
1433
|
+
end
|
1434
|
+
end
|
1435
|
+
|
1436
|
+
def test_no_remaining_tmp_files_excelx
|
1437
|
+
if EXCELX
|
1438
|
+
prev = Dir.glob(TMP_PREFIX)
|
1439
|
+
assert_raise(Zip::ZipError) { #TODO: besseres Fehlerkriterium bei
|
1440
|
+
|
1441
|
+
# oo = Excelx.new(File.join(TESTDIR,"no_spreadsheet_file.txt"))
|
1442
|
+
# es soll absichtlich ein Abbruch provoziert werden, deshalb :ignore
|
1443
|
+
oo = Excelx.new(File.join(TESTDIR,"no_spreadsheet_file.txt"),
|
1444
|
+
false,
|
1445
|
+
:ignore)
|
1446
|
+
|
1447
|
+
}
|
1448
|
+
now = Dir.glob(TMP_PREFIX)
|
1449
|
+
assert (now-prev).empty?
|
1450
|
+
end
|
1451
|
+
end
|
1452
|
+
|
1453
|
+
def test_no_remaining_tmp_files_google
|
1454
|
+
# Exception ist irgendwie anders, nochmal ansehen TODO:
|
1455
|
+
after Date.new(2011,6,19) do
|
1456
|
+
if GOOGLE
|
1457
|
+
prev = Dir.glob(TMP_PREFIX)
|
1458
|
+
assert_nothing_raised() {
|
1459
|
+
oo = Google.new(key_of("no_spreadsheet_file.txt"))
|
1460
|
+
}
|
1461
|
+
now = Dir.glob(TMP_PREFIX)
|
1462
|
+
assert (now-prev).empty?
|
1463
|
+
end
|
1464
|
+
end
|
1465
|
+
end
|
1466
|
+
|
1467
|
+
# Erstellt eine Liste aller Zellen im Spreadsheet. Dies ist nötig, weil ein einfacher
|
1468
|
+
# Textvergleich des XML-Outputs nicht funktioniert, da xml-builder die Attribute
|
1469
|
+
# nicht immer in der gleichen Reihenfolge erzeugt.
|
1470
|
+
def init_all_cells(oo,sheet)
|
1471
|
+
all = []
|
1472
|
+
oo.first_row(sheet).upto(oo.last_row(sheet)) do |row|
|
1473
|
+
oo.first_column(sheet).upto(oo.last_column(sheet)) do |col|
|
1474
|
+
unless oo.empty?(row,col,sheet)
|
1475
|
+
all << {:row => row.to_s,
|
1476
|
+
:column => col.to_s,
|
1477
|
+
:content => oo.cell(row,col,sheet).to_s,
|
1478
|
+
:type => oo.celltype(row,col,sheet).to_s,
|
1479
|
+
}
|
1480
|
+
end
|
1481
|
+
end
|
1482
|
+
end
|
1483
|
+
all
|
1484
|
+
end
|
1485
|
+
|
1486
|
+
def test_to_xml
|
1487
|
+
with_each_spreadsheet(:name=>'numbers1', :encoding => 'utf8') do |oo|
|
1488
|
+
assert_nothing_raised {oo.to_xml}
|
1489
|
+
sheetname = oo.sheets.first
|
1490
|
+
doc = Nokogiri::XML(oo.to_xml)
|
1491
|
+
sheet_count = 0
|
1492
|
+
doc.xpath('//spreadsheet/sheet').each {|tmpelem|
|
1493
|
+
sheet_count += 1
|
1494
|
+
}
|
1495
|
+
assert_equal 5, sheet_count
|
1496
|
+
doc.xpath('//spreadsheet/sheet').each { |xml_sheet|
|
1497
|
+
all_cells = init_all_cells(oo, sheetname)
|
1498
|
+
x = 0
|
1499
|
+
assert_equal sheetname, xml_sheet.attributes['name'].value
|
1500
|
+
xml_sheet.children.each {|cell|
|
1501
|
+
if cell.attributes['name']
|
1502
|
+
expected = [all_cells[x][:row],
|
1503
|
+
all_cells[x][:column],
|
1504
|
+
all_cells[x][:content],
|
1505
|
+
all_cells[x][:type],
|
1506
|
+
]
|
1507
|
+
result = [
|
1508
|
+
cell.attributes['row'],
|
1509
|
+
cell.attributes['column'],
|
1510
|
+
cell.content,
|
1511
|
+
cell.attributes['type'],
|
1512
|
+
]
|
1513
|
+
assert_equal expected, result
|
1514
|
+
x += 1
|
1515
|
+
end # if
|
1516
|
+
} # end of sheet
|
1517
|
+
sheetname = oo.sheets[oo.sheets.index(sheetname)+1]
|
1518
|
+
}
|
1519
|
+
end
|
1520
|
+
end
|
1521
|
+
|
1522
|
+
def test_bug_row_column_fixnum_float
|
1523
|
+
with_each_spreadsheet(:name=>'bug-row-column-fixnum-float', :format=>:excel) do |oo|
|
1524
|
+
assert_equal 42.5, oo.cell('b',2)
|
1525
|
+
assert_equal 43 , oo.cell('c',2)
|
1526
|
+
assert_equal ['hij',42.5, 43], oo.row(2)
|
1527
|
+
assert_equal ['def',42.5, 'nop'], oo.column(2)
|
1528
|
+
end
|
1529
|
+
end
|
1530
|
+
|
1531
|
+
def test_file_warning_default
|
1532
|
+
after Date.new(2011,7,18) do
|
1533
|
+
if OPENOFFICE
|
1534
|
+
prev = Dir.glob(TMP_PREFIX)
|
1535
|
+
assert_raises(TypeError, "test/numbers1.xls is not an openoffice spreadsheet") { oo = Openoffice.new(File.join(TESTDIR,"numbers1.xls")) }
|
1536
|
+
assert_raises(TypeError) { oo = Openoffice.new(File.join(TESTDIR,"numbers1.xlsx")) }
|
1537
|
+
now = Dir.glob(TMP_PREFIX)
|
1538
|
+
assert (now-prev).empty?
|
1539
|
+
end
|
1540
|
+
if EXCEL
|
1541
|
+
prev = Dir.glob(TMP_PREFIX)
|
1542
|
+
assert_raises(TypeError) { oo = Excel.new(File.join(TESTDIR,"numbers1.ods")) }
|
1543
|
+
assert_raises(TypeError) { oo = Excel.new(File.join(TESTDIR,"numbers1.xlsx")) }
|
1544
|
+
now = Dir.glob(TMP_PREFIX)
|
1545
|
+
assert (now-prev).empty?, "temporary directory was not removed"
|
1546
|
+
end
|
1547
|
+
if EXCELX
|
1548
|
+
prev = Dir.glob(TMP_PREFIX)
|
1549
|
+
assert_raises(TypeError) { oo = Excelx.new(File.join(TESTDIR,"numbers1.ods")) }
|
1550
|
+
assert_raises(TypeError) { oo = Excelx.new(File.join(TESTDIR,"numbers1.xls")) }
|
1551
|
+
now = Dir.glob(TMP_PREFIX)
|
1552
|
+
assert (now-prev).empty?
|
1553
|
+
end
|
1554
|
+
end
|
1555
|
+
end
|
1556
|
+
|
1557
|
+
def test_file_warning_error
|
1558
|
+
after Date.new(2011,7,22) do
|
1559
|
+
if OPENOFFICE
|
1560
|
+
prev = Dir.glob(TMP_PREFIX)
|
1561
|
+
assert_raises(TypeError) { oo = Openoffice.new(File.join(TESTDIR,"numbers1.xls"),false,:error) }
|
1562
|
+
assert_raises(TypeError) { oo = Openoffice.new(File.join(TESTDIR,"numbers1.xlsx"),false,:error) }
|
1563
|
+
now = Dir.glob(TMP_PREFIX)
|
1564
|
+
assert (now-prev).empty?
|
1565
|
+
end
|
1566
|
+
if EXCEL
|
1567
|
+
prev = Dir.glob(TMP_PREFIX)
|
1568
|
+
assert_raises(TypeError) { oo = Excel.new(File.join(TESTDIR,"numbers1.ods"),false,:error) }
|
1569
|
+
assert_raises(TypeError) { oo = Excel.new(File.join(TESTDIR,"numbers1.xlsx"),false,:error) }
|
1570
|
+
now = Dir.glob(TMP_PREFIX)
|
1571
|
+
assert (now-prev).empty?, "temporary directory was not deleted"
|
1572
|
+
end
|
1573
|
+
if EXCELX
|
1574
|
+
prev = Dir.glob(TMP_PREFIX)
|
1575
|
+
assert_raises(TypeError) { oo = Excelx.new(File.join(TESTDIR,"numbers1.ods"),false,:error) }
|
1576
|
+
assert_raises(TypeError) { oo = Excelx.new(File.join(TESTDIR,"numbers1.xls"),false,:error) }
|
1577
|
+
now = Dir.glob(TMP_PREFIX)
|
1578
|
+
assert (now-prev).empty?, "temporary directory was not deleted"
|
1579
|
+
end
|
1580
|
+
end
|
1581
|
+
end
|
1582
|
+
|
1583
|
+
def test_file_warning_warning
|
1584
|
+
after Date.new(2011,7,22) do
|
1585
|
+
if OPENOFFICE
|
1586
|
+
assert_nothing_raised(TypeError) {
|
1587
|
+
assert_raises(Zip::ZipError) {
|
1588
|
+
oo = Openoffice.new(File.join(TESTDIR,"numbers1.xls"),false, :warning)
|
1589
|
+
}
|
1590
|
+
}
|
1591
|
+
prev = Dir.glob(TMP_PREFIX)
|
1592
|
+
assert_nothing_raised(TypeError) {
|
1593
|
+
assert_raises(Errno::ENOENT) {
|
1594
|
+
oo = Openoffice.new(File.join(TESTDIR,"numbers1.xlsx"),false, :warning)
|
1595
|
+
}
|
1596
|
+
}
|
1597
|
+
now = Dir.glob(TMP_PREFIX)
|
1598
|
+
assert (now-prev).empty?
|
1599
|
+
end
|
1600
|
+
if EXCEL
|
1601
|
+
prev = Dir.glob(TMP_PREFIX)
|
1602
|
+
assert_nothing_raised(TypeError) {
|
1603
|
+
assert_raises(Ole::Storage::FormatError) {
|
1604
|
+
oo = Excel.new(File.join(TESTDIR,"numbers1.ods"),false, :warning) }
|
1605
|
+
}
|
1606
|
+
assert_nothing_raised(TypeError) {
|
1607
|
+
assert_raises(Ole::Storage::FormatError) {
|
1608
|
+
oo = Excel.new(File.join(TESTDIR,"numbers1.xlsx"),false, :warning) }
|
1609
|
+
}
|
1610
|
+
now = Dir.glob(TMP_PREFIX)
|
1611
|
+
assert (now-prev).empty?, "temporary directory was not removed"
|
1612
|
+
end
|
1613
|
+
if EXCELX
|
1614
|
+
prev = Dir.glob(TMP_PREFIX)
|
1615
|
+
assert_nothing_raised(TypeError) {
|
1616
|
+
assert_raises(Errno::ENOENT) {
|
1617
|
+
oo = Excelx.new(File.join(TESTDIR,"numbers1.ods"),false, :warning) }
|
1618
|
+
}
|
1619
|
+
assert_nothing_raised(TypeError) {
|
1620
|
+
assert_raises(Zip::ZipError) {
|
1621
|
+
oo = Excelx.new(File.join(TESTDIR,"numbers1.xls"),false, :warning) }
|
1622
|
+
}
|
1623
|
+
now = Dir.glob(TMP_PREFIX)
|
1624
|
+
assert (now-prev).empty?
|
1625
|
+
end
|
1626
|
+
end
|
1627
|
+
end
|
1628
|
+
|
1629
|
+
def test_file_warning_ignore
|
1630
|
+
after Date.new(2011,7,22) do
|
1631
|
+
if OPENOFFICE
|
1632
|
+
# Files, die eigentlich Openoffice-
|
1633
|
+
# Files sind, aber die falsche Endung haben.
|
1634
|
+
# Es soll ohne Fehlermeldung oder Warnung
|
1635
|
+
# oder Abbruch die Datei geoffnet werden
|
1636
|
+
|
1637
|
+
# xls
|
1638
|
+
assert_nothing_raised() {
|
1639
|
+
oo = Openoffice.new(File.join(TESTDIR,"type_openoffice.xls"),false, :ignore)
|
1640
|
+
}
|
1641
|
+
# xlsx
|
1642
|
+
assert_nothing_raised() {
|
1643
|
+
oo = Openoffice.new(File.join(TESTDIR,"type_openoffice.xlsx"),false, :ignore)
|
1644
|
+
}
|
1645
|
+
end
|
1646
|
+
if EXCEL
|
1647
|
+
assert_nothing_raised() {
|
1648
|
+
oo = Excel.new(File.join(TESTDIR,"type_excel.ods"),false, :ignore)
|
1649
|
+
}
|
1650
|
+
assert_nothing_raised() {
|
1651
|
+
oo = Excel.new(File.join(TESTDIR,"type_excel.xlsx"),false, :ignore)
|
1652
|
+
}
|
1653
|
+
end
|
1654
|
+
if EXCELX
|
1655
|
+
assert_nothing_raised() {
|
1656
|
+
oo = Excelx.new(File.join(TESTDIR,"type_excelx.ods"),false, :ignore)
|
1657
|
+
}
|
1658
|
+
assert_nothing_raised() {
|
1659
|
+
oo = Excelx.new(File.join(TESTDIR,"type_excelx.xls"),false, :ignore)
|
1660
|
+
}
|
1661
|
+
end
|
1662
|
+
=begin
|
1663
|
+
if OPENOFFICE
|
1664
|
+
assert_nothing_raised() {
|
1665
|
+
assert_raises(Zip::ZipError) {
|
1666
|
+
oo = Openoffice.new(File.join(TESTDIR,"numbers1.xls"),false, :ignore) }
|
1667
|
+
}
|
1668
|
+
assert_nothing_raised() {
|
1669
|
+
assert_raises(Errno::ENOENT) {
|
1670
|
+
oo = Openoffice.new(File.join(TESTDIR,"numbers1.xlsx"),false, :ignore) }
|
1671
|
+
}
|
1672
|
+
assert Dir.glob(TMP_PREFIX).empty?
|
1673
|
+
end
|
1674
|
+
if EXCEL
|
1675
|
+
assert_nothing_raised(TypeError) {
|
1676
|
+
assert_raises(Ole::Storage::FormatError) {
|
1677
|
+
oo = Excel.new(File.join(TESTDIR,"numbers1.ods"),false, :ignore) }
|
1678
|
+
}
|
1679
|
+
assert_nothing_raised(TypeError) {
|
1680
|
+
assert_raises(Ole::Storage::FormatError) {oo = Excel.new(File.join(TESTDIR,"numbers1.xlsx"),false, :ignore) }}
|
1681
|
+
assert Dir.glob(TMP_PREFIX).empty?
|
1682
|
+
end
|
1683
|
+
if EXCELX
|
1684
|
+
assert_nothing_raised(TypeError) {
|
1685
|
+
assert_raises(Errno::ENOENT) {
|
1686
|
+
oo = Excelx.new(File.join(TESTDIR,"numbers1.ods"),false, :ignore)
|
1687
|
+
}
|
1688
|
+
}
|
1689
|
+
assert_nothing_raised(TypeError) {
|
1690
|
+
assert_raises(Zip::ZipError) {
|
1691
|
+
oo = Excelx.new(File.join(TESTDIR,"numbers1.xls"),false, :ignore)
|
1692
|
+
}
|
1693
|
+
}
|
1694
|
+
assert Dir.glob(TMP_PREFIX).empty?
|
1695
|
+
end
|
1696
|
+
=end
|
1697
|
+
end
|
1698
|
+
end
|
1699
|
+
|
1700
|
+
def test_bug_last_row_excel
|
1701
|
+
with_each_spreadsheet(:name=>'time-test', :format=>:excel) do |oo|
|
1702
|
+
assert_equal 2, oo.last_row
|
1703
|
+
end
|
1704
|
+
end
|
1705
|
+
|
1706
|
+
def test_bug_to_xml_with_empty_sheets
|
1707
|
+
with_each_spreadsheet(:name=>'emptysheets', :format=>[:openoffice, :excel]) do |oo|
|
1708
|
+
oo.sheets.each { |sheet|
|
1709
|
+
assert_equal nil, oo.first_row, "first_row not nil in sheet #{sheet}"
|
1710
|
+
assert_equal nil, oo.last_row, "last_row not nil in sheet #{sheet}"
|
1711
|
+
assert_equal nil, oo.first_column, "first_column not nil in sheet #{sheet}"
|
1712
|
+
assert_equal nil, oo.last_column, "last_column not nil in sheet #{sheet}"
|
1713
|
+
assert_equal nil, oo.first_row(sheet), "first_row not nil in sheet #{sheet}"
|
1714
|
+
assert_equal nil, oo.last_row(sheet), "last_row not nil in sheet #{sheet}"
|
1715
|
+
assert_equal nil, oo.first_column(sheet), "first_column not nil in sheet #{sheet}"
|
1716
|
+
assert_equal nil, oo.last_column(sheet), "last_column not nil in sheet #{sheet}"
|
1717
|
+
}
|
1718
|
+
assert_nothing_raised() { result = oo.to_xml }
|
1719
|
+
end
|
1720
|
+
end
|
1721
|
+
|
1722
|
+
def test_bug_simple_spreadsheet_time_bug
|
1723
|
+
# really a bug? are cells really of type time?
|
1724
|
+
# No! :float must be the correct type
|
1725
|
+
with_each_spreadsheet(:name=>'simple_spreadsheet', :format=>:excelx) do |oo|
|
1726
|
+
# puts oo.cell('B',5).to_s
|
1727
|
+
# assert_equal :time, oo.celltype('B',5)
|
1728
|
+
assert_equal :float, oo.celltype('B',5)
|
1729
|
+
assert_equal 10.75, oo.cell('B',5)
|
1730
|
+
assert_equal 12.50, oo.cell('C',5)
|
1731
|
+
assert_equal 0, oo.cell('D',5)
|
1732
|
+
assert_equal 1.75, oo.cell('E',5)
|
1733
|
+
assert_equal 'Task 1', oo.cell('F',5)
|
1734
|
+
assert_equal Date.new(2007,5,7), oo.cell('A',5)
|
1735
|
+
end
|
1736
|
+
end
|
1737
|
+
|
1738
|
+
def test_simple2_excelx
|
1739
|
+
with_each_spreadsheet(:name=>'simple_spreadsheet', :format=>:excelx) do |oo|
|
1740
|
+
assert_equal [:numeric_or_formula, "yyyy\\-mm\\-dd"], oo.excelx_type('A',4)
|
1741
|
+
assert_equal [:numeric_or_formula, "#,##0.00"], oo.excelx_type('B',4)
|
1742
|
+
assert_equal [:numeric_or_formula, "#,##0.00"], oo.excelx_type('c',4)
|
1743
|
+
assert_equal [:numeric_or_formula, "General"], oo.excelx_type('d',4)
|
1744
|
+
assert_equal [:numeric_or_formula, "General"], oo.excelx_type('e',4)
|
1745
|
+
assert_equal :string, oo.excelx_type('f',4)
|
1746
|
+
|
1747
|
+
assert_equal "39209", oo.excelx_value('a',4)
|
1748
|
+
assert_equal "yyyy\\-mm\\-dd", oo.excelx_format('a',4)
|
1749
|
+
assert_equal "9.25", oo.excelx_value('b',4)
|
1750
|
+
assert_equal "10.25", oo.excelx_value('c',4)
|
1751
|
+
assert_equal "0", oo.excelx_value('d',4)
|
1752
|
+
#... Sum-Spalte
|
1753
|
+
# assert_equal "Task 1", oo.excelx_value('f',4)
|
1754
|
+
assert_equal "Task 1", oo.cell('f',4)
|
1755
|
+
assert_equal Date.new(2007,05,07), oo.cell('a',4)
|
1756
|
+
assert_equal "9.25", oo.excelx_value('b',4)
|
1757
|
+
assert_equal "#,##0.00", oo.excelx_format('b',4)
|
1758
|
+
assert_equal 9.25, oo.cell('b',4)
|
1759
|
+
assert_equal :float, oo.celltype('b',4)
|
1760
|
+
assert_equal :float, oo.celltype('d',4)
|
1761
|
+
assert_equal 0, oo.cell('d',4)
|
1762
|
+
assert_equal :formula, oo.celltype('e',4)
|
1763
|
+
assert_equal 1, oo.cell('e',4)
|
1764
|
+
assert_equal 'C4-B4-D4', oo.formula('e',4)
|
1765
|
+
assert_equal :string, oo.celltype('f',4)
|
1766
|
+
assert_equal "Task 1", oo.cell('f',4)
|
1767
|
+
end
|
1768
|
+
end
|
1769
|
+
|
1770
|
+
def test_datetime
|
1771
|
+
with_each_spreadsheet(:name=>'datetime') do |oo|
|
1772
|
+
val = oo.cell('c',3)
|
1773
|
+
assert_kind_of DateTime, val
|
1774
|
+
assert_equal :datetime, oo.celltype('c',3)
|
1775
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), val
|
1776
|
+
val = oo.cell('a',1)
|
1777
|
+
assert_kind_of Date, val
|
1778
|
+
assert_equal :date, oo.celltype('a',1)
|
1779
|
+
assert_equal Date.new(1961,11,21), val
|
1780
|
+
assert_equal Date.new(1961,11,21), oo.cell('a',1)
|
1781
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('a',3)
|
1782
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('b',3)
|
1783
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('c',3)
|
1784
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('a',4)
|
1785
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('b',4)
|
1786
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('c',4)
|
1787
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('a',5)
|
1788
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('b',5)
|
1789
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('c',5)
|
1790
|
+
assert_equal Date.new(1961,11,21), oo.cell('a',6)
|
1791
|
+
assert_equal Date.new(1961,11,21), oo.cell('b',6)
|
1792
|
+
assert_equal Date.new(1961,11,21), oo.cell('c',6)
|
1793
|
+
assert_equal Date.new(1961,11,21), oo.cell('a',7)
|
1794
|
+
assert_equal Date.new(1961,11,21), oo.cell('b',7)
|
1795
|
+
assert_equal Date.new(1961,11,21), oo.cell('c',7)
|
1796
|
+
end
|
1797
|
+
end
|
1798
|
+
|
1799
|
+
def test_cell_openoffice_html_escape
|
1800
|
+
with_each_spreadsheet(:name=>'html-escape', :format=>:openoffice) do |oo|
|
1801
|
+
assert_equal "'", oo.cell(1,1)
|
1802
|
+
assert_equal "&", oo.cell(2,1)
|
1803
|
+
assert_equal ">", oo.cell(3,1)
|
1804
|
+
assert_equal "<", oo.cell(4,1)
|
1805
|
+
assert_equal "`", oo.cell(5,1)
|
1806
|
+
# test_openoffice_zipped will catch issues with "
|
1807
|
+
end
|
1808
|
+
end
|
1809
|
+
|
1810
|
+
def test_cell_boolean
|
1811
|
+
with_each_spreadsheet(:name=>'boolean', :format=>[:openoffice, :excel, :excelx]) do |oo|
|
1812
|
+
if oo.class == Excelx
|
1813
|
+
assert_equal "TRUE", oo.cell(1,1), "failure in "+oo.class.to_s
|
1814
|
+
assert_equal "FALSE", oo.cell(2,1), "failure in "+oo.class.to_s
|
1815
|
+
else
|
1816
|
+
assert_equal "true", oo.cell(1,1), "failure in "+oo.class.to_s
|
1817
|
+
assert_equal "false", oo.cell(2,1), "failure in "+oo.class.to_s
|
1818
|
+
end
|
1819
|
+
end
|
1820
|
+
end
|
1821
|
+
|
1822
|
+
def test_cell_multiline
|
1823
|
+
with_each_spreadsheet(:name=>'paragraph', :format=>[:openoffice, :excel, :excelx]) do |oo|
|
1824
|
+
assert_equal "This is a test\nof a multiline\nCell", oo.cell(1,1)
|
1825
|
+
assert_equal "This is a test\n¶\nof a multiline\n\nCell", oo.cell(1,2)
|
1826
|
+
assert_equal "first p\n\nsecond p\n\nlast p", oo.cell(2,1)
|
1827
|
+
end
|
1828
|
+
end
|
1829
|
+
|
1830
|
+
def test_cell_styles
|
1831
|
+
# styles only valid in excel spreadsheets?
|
1832
|
+
# TODO: what todo with other spreadsheet types
|
1833
|
+
with_each_spreadsheet(:name=>'style', :format=>[# :openoffice,
|
1834
|
+
:excel,
|
1835
|
+
# :excelx
|
1836
|
+
]) do |oo|
|
1837
|
+
# bold
|
1838
|
+
assert_equal true, oo.font(1,1).bold?
|
1839
|
+
assert_equal false, oo.font(1,1).italic?
|
1840
|
+
assert_equal false, oo.font(1,1).underline?
|
1841
|
+
|
1842
|
+
# italic
|
1843
|
+
assert_equal false, oo.font(2,1).bold?
|
1844
|
+
assert_equal true, oo.font(2,1).italic?
|
1845
|
+
assert_equal false, oo.font(2,1).underline?
|
1846
|
+
|
1847
|
+
# normal
|
1848
|
+
assert_equal false, oo.font(3,1).bold?
|
1849
|
+
assert_equal false, oo.font(3,1).italic?
|
1850
|
+
assert_equal false, oo.font(3,1).underline?
|
1851
|
+
|
1852
|
+
# underline
|
1853
|
+
assert_equal false, oo.font(4,1).bold?
|
1854
|
+
assert_equal false, oo.font(4,1).italic?
|
1855
|
+
assert_equal true, oo.font(4,1).underline?
|
1856
|
+
|
1857
|
+
# bold italic
|
1858
|
+
assert_equal true, oo.font(5,1).bold?
|
1859
|
+
assert_equal true, oo.font(5,1).italic?
|
1860
|
+
assert_equal false, oo.font(5,1).underline?
|
1861
|
+
|
1862
|
+
# bold underline
|
1863
|
+
assert_equal true, oo.font(6,1).bold?
|
1864
|
+
assert_equal false, oo.font(6,1).italic?
|
1865
|
+
assert_equal true, oo.font(6,1).underline?
|
1866
|
+
|
1867
|
+
# italic underline
|
1868
|
+
assert_equal false, oo.font(7,1).bold?
|
1869
|
+
assert_equal true, oo.font(7,1).italic?
|
1870
|
+
assert_equal true, oo.font(7,1).underline?
|
1871
|
+
|
1872
|
+
# bolded row
|
1873
|
+
assert_equal true, oo.font(8,1).bold?
|
1874
|
+
assert_equal false, oo.font(8,1).italic?
|
1875
|
+
assert_equal false, oo.font(8,1).underline?
|
1876
|
+
|
1877
|
+
# bolded col
|
1878
|
+
assert_equal true, oo.font(9,2).bold?
|
1879
|
+
assert_equal false, oo.font(9,2).italic?
|
1880
|
+
assert_equal false, oo.font(9,2).underline?
|
1881
|
+
|
1882
|
+
# bolded row, italic col
|
1883
|
+
assert_equal true, oo.font(10,3).bold?
|
1884
|
+
assert_equal true, oo.font(10,3).italic?
|
1885
|
+
assert_equal false, oo.font(10,3).underline?
|
1886
|
+
|
1887
|
+
# normal
|
1888
|
+
assert_equal false, oo.font(11,4).bold?
|
1889
|
+
assert_equal false, oo.font(11,4).italic?
|
1890
|
+
assert_equal false, oo.font(11,4).underline?
|
1891
|
+
end
|
1892
|
+
end
|
1893
|
+
|
1894
|
+
# If a cell has a date-like string but is preceeded by a '
|
1895
|
+
# to force that date to be treated like a string, we were getting an exception.
|
1896
|
+
# This test just checks for that exception to make sure it's not raised in this case
|
1897
|
+
def test_date_to_float_conversion
|
1898
|
+
with_each_spreadsheet(:name=>'datetime_floatconv', :format=>:excel) do |oo|
|
1899
|
+
assert_nothing_raised(NoMethodError) do
|
1900
|
+
oo.cell('a',1)
|
1901
|
+
oo.cell('a',2)
|
1902
|
+
end
|
1903
|
+
end
|
1904
|
+
end
|
1905
|
+
|
1906
|
+
# Need to extend to other formats
|
1907
|
+
def test_row_whitespace
|
1908
|
+
# auf dieses Dokument habe ich keinen Zugriff TODO:
|
1909
|
+
with_each_spreadsheet(:name=>'whitespace') do |oo|
|
1910
|
+
oo.default_sheet = "Sheet1"
|
1911
|
+
assert_equal [nil, nil, nil, nil, nil, nil], oo.row(1)
|
1912
|
+
assert_equal [nil, nil, nil, nil, nil, nil], oo.row(2)
|
1913
|
+
assert_equal ["Date", "Start time", "End time", "Pause", "Sum", "Comment"], oo.row(3)
|
1914
|
+
assert_equal [Date.new(2007,5,7), 9.25, 10.25, 0.0, 1.0, "Task 1"], oo.row(4)
|
1915
|
+
assert_equal [nil, nil, nil, nil, nil, nil], oo.row(5)
|
1916
|
+
assert_equal [Date.new(2007,5,7), 10.75, 10.75, 0.0, 0.0, "Task 1"], oo.row(6)
|
1917
|
+
oo.default_sheet = "Sheet2"
|
1918
|
+
assert_equal ["Date", nil, "Start time"], oo.row(1)
|
1919
|
+
assert_equal [Date.new(2007,5,7), nil, 9.25], oo.row(2)
|
1920
|
+
assert_equal [Date.new(2007,5,7), nil, 10.75], oo.row(3)
|
1921
|
+
end
|
1922
|
+
end
|
1923
|
+
|
1924
|
+
def test_col_whitespace
|
1925
|
+
#TODO:
|
1926
|
+
# kein Zugriff auf Dokument whitespace
|
1927
|
+
with_each_spreadsheet(:name=>'whitespace') do |oo|
|
1928
|
+
oo.default_sheet = "Sheet1"
|
1929
|
+
assert_equal ["Date", Date.new(2007,5,7), nil, Date.new(2007,5,7)], oo.column(1)
|
1930
|
+
assert_equal ["Start time", 9.25, nil, 10.75], oo.column(2)
|
1931
|
+
assert_equal ["End time", 10.25, nil, 10.75], oo.column(3)
|
1932
|
+
assert_equal ["Pause", 0.0, nil, 0.0], oo.column(4)
|
1933
|
+
assert_equal ["Sum", 1.0, nil, 0.0], oo.column(5)
|
1934
|
+
assert_equal ["Comment","Task 1", nil, "Task 1"], oo.column(6)
|
1935
|
+
oo.default_sheet = "Sheet2"
|
1936
|
+
assert_equal [nil, nil, nil], oo.column(1)
|
1937
|
+
assert_equal [nil, nil, nil], oo.column(2)
|
1938
|
+
assert_equal ["Date", Date.new(2007,5,7), Date.new(2007,5,7)], oo.column(3)
|
1939
|
+
assert_equal [nil, nil, nil], oo.column(4)
|
1940
|
+
assert_equal [ "Start time", 9.25, 10.75], oo.column(5)
|
1941
|
+
end
|
1942
|
+
end
|
1943
|
+
|
1944
|
+
# Excel has two base date formats one from 1900 and the other from 1904.
|
1945
|
+
# There's a MS bug that 1900 base dates include an extra day due to erroneously
|
1946
|
+
# including 1900 as a leap yar.
|
1947
|
+
def test_base_dates_in_excel
|
1948
|
+
with_each_spreadsheet(:name=>'1900_base', :format=>:excel) do |oo|
|
1949
|
+
assert_equal Date.new(2009,06,15), oo.cell(1,1)
|
1950
|
+
#we don't want to to 'interpret' formulas assert_equal Date.new(Time.now.year,Time.now.month,Time.now.day), oo.cell(2,1) #formula for TODAY()
|
1951
|
+
# if we test TODAY() we have also have to calculate
|
1952
|
+
# other date calculations
|
1953
|
+
#
|
1954
|
+
assert_equal :date, oo.celltype(1,1)
|
1955
|
+
end
|
1956
|
+
with_each_spreadsheet(:name=>'1904_base', :format=>:excel) do |oo|
|
1957
|
+
assert_equal Date.new(2009,06,15), oo.cell(1,1)
|
1958
|
+
# see comment above
|
1959
|
+
# assert_equal Date.new(Time.now.year,Time.now.month,Time.now.day), oo.cell(2,1) #formula for TODAY()
|
1960
|
+
assert_equal :date, oo.celltype(1,1)
|
1961
|
+
end
|
1962
|
+
end
|
1963
|
+
|
1964
|
+
def test_bad_date
|
1965
|
+
with_each_spreadsheet(:name=>'prova', :format=>:excel) do |oo|
|
1966
|
+
assert_nothing_raised(ArgumentError) {
|
1967
|
+
assert_equal DateTime.new(2006,2,2,10,0,0), oo.cell('a',1)
|
1968
|
+
}
|
1969
|
+
end # each
|
1970
|
+
end
|
1971
|
+
|
1972
|
+
def test_cell_methods
|
1973
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
1974
|
+
assert_equal 10, oo.a4 # cell(4,'A')
|
1975
|
+
assert_equal 11, oo.b4 # cell(4,'B')
|
1976
|
+
assert_equal 12, oo.c4 # cell(4,'C')
|
1977
|
+
assert_equal 13, oo.d4 # cell(4,'D')
|
1978
|
+
assert_equal 14, oo.e4 # cell(4,'E')
|
1979
|
+
assert_equal 'ABC', oo.c6('Sheet5')
|
1980
|
+
|
1981
|
+
#assert_raises(ArgumentError) {
|
1982
|
+
assert_raises(NoMethodError) {
|
1983
|
+
# a42a is not a valid cell name, should raise ArgumentError
|
1984
|
+
assert_equal 9999, oo.a42a
|
1985
|
+
}
|
1986
|
+
end
|
1987
|
+
end
|
1988
|
+
|
1989
|
+
|
1990
|
+
# compare large spreadsheets
|
1991
|
+
def test_compare_large_spreadsheets
|
1992
|
+
# problematisch, weil Formeln in Excel nicht unterstützt werden
|
1993
|
+
if LONG_RUN
|
1994
|
+
qq = Openoffice.new(File.join('test',"Bibelbund.ods"))
|
1995
|
+
with_each_spreadsheet(:name=>'Bibelbund') do |oo|
|
1996
|
+
# p "comparing Bibelbund.ods with #{oo.class}"
|
1997
|
+
oo.sheets.each do |sh|
|
1998
|
+
oo.first_row.upto(oo.last_row) do |row|
|
1999
|
+
oo.first_column.upto(oo.last_column) do |col|
|
2000
|
+
c1 = qq.cell(row,col,sh)
|
2001
|
+
c1.force_encoding("UTF-8") if c1.class == String
|
2002
|
+
c2 = oo.cell(row,col,sh)
|
2003
|
+
c2.force_encoding("UTF-8") if c2.class == String
|
2004
|
+
assert_equal c1, c2, "diff in #{sh}/#{row}/#{col}}"
|
2005
|
+
assert_equal qq.celltype(row,col,sh), oo.celltype(row,col,sh)
|
2006
|
+
assert_equal qq.formula?(row,col,sh), oo.formula?(row,col,sh) if oo.class != Excel
|
2007
|
+
end
|
2008
|
+
end
|
2009
|
+
end
|
2010
|
+
end
|
2011
|
+
end # LONG_RUN
|
2012
|
+
end
|
2013
|
+
|
2014
|
+
def test_labeled_cells
|
2015
|
+
# to do
|
2016
|
+
# "more spreadsheet types"
|
2017
|
+
# end
|
2018
|
+
with_each_spreadsheet(:name=>'named_cells', :format=>:openoffice) do |oo|
|
2019
|
+
oo.default_sheet = oo.sheets.first
|
2020
|
+
begin
|
2021
|
+
row,col = oo.label('anton')
|
2022
|
+
rescue ArgumentError
|
2023
|
+
puts "labels error at #{oo.class}"
|
2024
|
+
raise
|
2025
|
+
end
|
2026
|
+
assert_equal 5, row
|
2027
|
+
assert_equal 3, col
|
2028
|
+
|
2029
|
+
row,col = oo.label('anton')
|
2030
|
+
assert_equal 'Anton', oo.cell(row,col)
|
2031
|
+
|
2032
|
+
row,col = oo.label('berta')
|
2033
|
+
assert_equal 'Bertha', oo.cell(row,col)
|
2034
|
+
|
2035
|
+
row,col = oo.label('caesar')
|
2036
|
+
assert_equal 'Cäsar', oo.cell(row,col)
|
2037
|
+
|
2038
|
+
row,col = oo.label('never')
|
2039
|
+
assert_nil row
|
2040
|
+
assert_nil col
|
2041
|
+
|
2042
|
+
row,col,sheet = oo.label('anton')
|
2043
|
+
assert_equal 5, row
|
2044
|
+
assert_equal 3, col
|
2045
|
+
assert_equal "Sheet1", sheet
|
2046
|
+
|
2047
|
+
assert_equal "Anton", oo.anton
|
2048
|
+
assert_raises(NoMethodError) {
|
2049
|
+
row,col = oo.never
|
2050
|
+
}
|
2051
|
+
end
|
2052
|
+
end
|
2053
|
+
|
2054
|
+
|
2055
|
+
def test_bug_excel_last_row_255
|
2056
|
+
if LONG_RUN
|
2057
|
+
local_only do
|
2058
|
+
after Date.new(2011,6,17) do
|
2059
|
+
oo = Excel.new(File.join('..','confidential','ScienceStaff.xls'))
|
2060
|
+
oo.default_sheet = oo.sheets.first
|
2061
|
+
assert_equal "COMSCI", oo.cell(255,1)
|
2062
|
+
assert_equal "lala", oo.cell(256,1)
|
2063
|
+
assert_equal 1537, oo.last_row
|
2064
|
+
end
|
2065
|
+
end
|
2066
|
+
end
|
2067
|
+
end
|
2068
|
+
|
2069
|
+
def test_bug_excel_last_row_255_modified
|
2070
|
+
local_only do
|
2071
|
+
oo = Excel.new(File.join('..','confidential','ScienceStaff_modified.xls'))
|
2072
|
+
oo.default_sheet = oo.sheets.first
|
2073
|
+
assert_equal 1537, oo.last_row
|
2074
|
+
end
|
2075
|
+
end
|
2076
|
+
|
2077
|
+
require 'matrix'
|
2078
|
+
def test_matrix
|
2079
|
+
with_each_spreadsheet(:name => 'matrix', :format => [:openoffice, :excel, :google]) do |oo|
|
2080
|
+
oo.default_sheet = oo.sheets.first
|
2081
|
+
assert_equal Matrix[
|
2082
|
+
[1.0, 2.0, 3.0],
|
2083
|
+
[4.0, 5.0, 6.0],
|
2084
|
+
[7.0, 8.0, 9.0] ], oo.to_matrix
|
2085
|
+
end
|
2086
|
+
end
|
2087
|
+
|
2088
|
+
def test_matrix_selected_range
|
2089
|
+
with_each_spreadsheet(:name => 'matrix', :format=>[:excel,:openoffice,:google]) do |oo|
|
2090
|
+
oo.default_sheet = 'Sheet2'
|
2091
|
+
assert_equal Matrix[
|
2092
|
+
[1.0, 2.0, 3.0],
|
2093
|
+
[4.0, 5.0, 6.0],
|
2094
|
+
[7.0, 8.0, 9.0] ], oo.to_matrix(3,4,5,6)
|
2095
|
+
end
|
2096
|
+
end
|
2097
|
+
|
2098
|
+
def test_matrix_all_nil
|
2099
|
+
with_each_spreadsheet(:name => 'matrix', :format=>[:excel,:openoffice,:google]) do |oo|
|
2100
|
+
oo.default_sheet = 'Sheet2'
|
2101
|
+
assert_equal Matrix[
|
2102
|
+
[nil, nil, nil],
|
2103
|
+
[nil, nil, nil],
|
2104
|
+
[nil, nil, nil] ], oo.to_matrix(10,10,12,12)
|
2105
|
+
end
|
2106
|
+
end
|
2107
|
+
|
2108
|
+
def test_matrix_values_and_nil
|
2109
|
+
with_each_spreadsheet(:name => 'matrix', :format=>[:excel,:openoffice,:google]) do |oo|
|
2110
|
+
oo.default_sheet = 'Sheet3'
|
2111
|
+
assert_equal Matrix[
|
2112
|
+
[1.0, nil, 3.0],
|
2113
|
+
[4.0, 5.0, 6.0],
|
2114
|
+
[7.0, 8.0, nil] ], oo.to_matrix(1,1,3,3)
|
2115
|
+
end end
|
2116
|
+
|
2117
|
+
def test_bug_date_mileszs
|
2118
|
+
after Date.new(2011,7,17) do
|
2119
|
+
# to do
|
2120
|
+
# "An richtige Stelle kopieren. Ist das Dokument vertraulich?"
|
2121
|
+
# 'ist auf dem Netbook nicht vorhanden'
|
2122
|
+
# end
|
2123
|
+
oo = Excel.new "/home/tp/Documents/feb-sales-analysis.xls"
|
2124
|
+
oo.default_sheet = oo.sheets.first
|
2125
|
+
# 2/1/2010 A2-A6 mm/dd/yyyy
|
2126
|
+
2.upto(6) do |i|
|
2127
|
+
assert_equal Date.new(2010,2,1), oo.cell('A',i)
|
2128
|
+
end
|
2129
|
+
end
|
2130
|
+
end
|
2131
|
+
|
2132
|
+
#def test_no_generic_new
|
2133
|
+
#oo = GenericSpreadsheet.new
|
2134
|
+
#assert_equal GenericSpreadsheet, oo.class
|
2135
|
+
#end
|
2136
|
+
|
2137
|
+
# unter Windows soll es laut Bug-Reports nicht moeglich sein, eine Excel-Datei, die
|
2138
|
+
# mit Excel.new geoeffnet wurde nach dem Processing anschliessend zu loeschen.
|
2139
|
+
# Anmerkung: Das Spreadsheet-Gem erlaubt kein explizites Close von Spreadsheet-Dateien,
|
2140
|
+
# was verhindern koennte, das die Datei geloescht werden kann.
|
2141
|
+
def test_bug_cannot_delete_opened_excel_sheet
|
2142
|
+
# with_each_spreadsheet(:name=>'simple_spreadsheet') do |oo|
|
2143
|
+
after Date.new(2011,7,17) do
|
2144
|
+
# to do
|
2145
|
+
# 'kopiere nach temporaere Datei
|
2146
|
+
# und versuche diese zu oeffnen und zu loeschen'
|
2147
|
+
# end
|
2148
|
+
end
|
2149
|
+
#end
|
2150
|
+
end
|
2151
|
+
|
2152
|
+
def test_bug_xlsx_reference_cell
|
2153
|
+
=begin
|
2154
|
+
If cell A contains a string and cell B references cell A. When reading the value of cell B, the result will be
|
2155
|
+
"0.0" instead of the value of cell A.
|
2156
|
+
|
2157
|
+
With the attached test case, I ran the following code:
|
2158
|
+
spreadsheet = Excelx.new('formula_string_error.xlsx')
|
2159
|
+
spreadsheet.default_sheet = 'sheet1'
|
2160
|
+
p "A: #{spreadsheet.cell(1, 1)}"
|
2161
|
+
p "B: #{spreadsheet.cell(2, 1)}"
|
2162
|
+
|
2163
|
+
with the following results
|
2164
|
+
"A: TestString"
|
2165
|
+
"B: 0.0"
|
2166
|
+
|
2167
|
+
where the expected result is
|
2168
|
+
"A: TestString"
|
2169
|
+
"B: TestString"
|
2170
|
+
=end
|
2171
|
+
xlsx = Excelx.new(File.join('test', "formula_string_error.xlsx"))
|
2172
|
+
xlsx.default_sheet = xlsx.sheets.first
|
2173
|
+
assert_equal 'Teststring', xlsx.cell('a',1)
|
2174
|
+
assert_equal 'Teststring', xlsx.cell('a',2)
|
2175
|
+
end
|
2176
|
+
|
2177
|
+
def test_bug_guest_list_2011_05_05
|
2178
|
+
after Date.new(2011,7,17) do
|
2179
|
+
oo = Excel.new(File.join("..","confidential","guest_list_addresses.xls"))
|
2180
|
+
oo.default_sheet = oo.sheets.first
|
2181
|
+
assert_equal "lalala", oo.cell('a',1) # anderer Inhalt im Spreadsheet
|
2182
|
+
assert_equal :string, oo.celltype('a',1)
|
2183
|
+
end
|
2184
|
+
end
|
2185
|
+
|
2186
|
+
def test_bug_guest_list_2011_05_05_spreadsheet
|
2187
|
+
# to do
|
2188
|
+
# 'wieder entfernen'
|
2189
|
+
# end
|
2190
|
+
require 'spreadsheet'
|
2191
|
+
book = Spreadsheet.open File.join('..','confidential','guest_list_addresses.xls')
|
2192
|
+
sheet1 = book.worksheet 0
|
2193
|
+
sheet1.each do |row|
|
2194
|
+
p row[0]
|
2195
|
+
|
2196
|
+
end
|
2197
|
+
end
|
2198
|
+
|
2199
|
+
# don't test it with other spreadsheet types! this was only a problem
|
2200
|
+
# with .xlsx files
|
2201
|
+
def test_bug_date_not_recognized_2011_05_21
|
2202
|
+
#oo = Excelx.new(File.join(TESTDIR,'2011-05-21_sample_date_problem.xlsx'))
|
2203
|
+
oo = Excelx.new(File.join('..','confidential','2011-05-21_sample_date_problem.xlsx'))
|
2204
|
+
oo.default_sheet = oo.sheets.first
|
2205
|
+
assert_equal Date.new(2011,3,24), oo.b4
|
2206
|
+
assert_equal Date.new(2011,3,25), oo.b5
|
2207
|
+
assert_equal Date.new(2011,5,5), oo.b6
|
2208
|
+
assert_equal Date.new(2012,3,23), oo.b7
|
2209
|
+
end
|
2210
|
+
|
2211
|
+
def test_bug_string_as_a_date_2011_05_21_spreadsheet_only
|
2212
|
+
after Date.new(2011,6,24) do
|
2213
|
+
# to do
|
2214
|
+
# 'wieder entfernen'
|
2215
|
+
# end
|
2216
|
+
require 'spreadsheet'
|
2217
|
+
book = Spreadsheet.open File.join('..','confidential','2011-05-21_sample_type_problem.xls')
|
2218
|
+
sheet1 = book.worksheet 0
|
2219
|
+
sheet1.each_with_index do |row,rownum|
|
2220
|
+
# p row[0]
|
2221
|
+
if rownum == 2
|
2222
|
+
assert_equal 68, row[6]
|
2223
|
+
end
|
2224
|
+
|
2225
|
+
end
|
2226
|
+
end
|
2227
|
+
end
|
2228
|
+
|
2229
|
+
def test_bug_string_as_a_date_2011_05_21
|
2230
|
+
after Date.new(2011,7,22) do
|
2231
|
+
#oo = Excel.new(File.join(TESTDIR,'2011-05-21_sample_type_problem.xls'))
|
2232
|
+
oo = Excel.new(File.join('..','confidential','2011-05-21_sample_type_problem.xls'))
|
2233
|
+
oo.default_sheet = oo.sheets.first
|
2234
|
+
assert_equal 68, oo.g2
|
2235
|
+
assert_equal 72, oo.g3
|
2236
|
+
assert_equal 75, oo.g4
|
2237
|
+
assert_equal 76, oo.g5
|
2238
|
+
assert_equal 77, oo.g6
|
2239
|
+
assert_equal 78, oo.g7
|
2240
|
+
end
|
2241
|
+
end
|
2242
|
+
|
2243
|
+
def test_bug_string_as_a_date_2011_05_21_saved_as_ods
|
2244
|
+
#oo = Openoffice.new(File.join(TESTDIR,'2011-05-21_sample_type_problem.ods'))
|
2245
|
+
oo = Openoffice.new(File.join('..','confidential','2011-05-21_sample_type_problem.ods'))
|
2246
|
+
oo.default_sheet = oo.sheets.first
|
2247
|
+
assert_equal 68, oo.g2
|
2248
|
+
assert_equal 72, oo.g3
|
2249
|
+
assert_equal 75, oo.g4
|
2250
|
+
assert_equal 76, oo.g5
|
2251
|
+
assert_equal 77, oo.g6
|
2252
|
+
assert_equal 78, oo.g7
|
2253
|
+
end
|
2254
|
+
end # class
|