roo 2.0.1 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +16 -1
- data/README.md +8 -11
- data/lib/roo/base.rb +84 -84
- data/lib/roo/constants.rb +5 -0
- data/lib/roo/excelx/shared_strings.rb +10 -0
- data/lib/roo/excelx.rb +12 -13
- data/lib/roo/libre_office.rb +1 -2
- data/lib/roo/open_office.rb +454 -521
- data/lib/roo/spreadsheet.rb +3 -1
- data/lib/roo/version.rb +1 -1
- data/lib/roo.rb +5 -3
- data/spec/helpers.rb +5 -0
- data/spec/lib/roo/base_spec.rb +212 -0
- data/spec/lib/roo/excelx_spec.rb +13 -0
- data/spec/lib/roo/spreadsheet_spec.rb +20 -0
- data/spec/spec_helper.rb +6 -1
- data/test/all_ss.rb +12 -11
- data/test/test_helper.rb +0 -4
- data/test/test_roo.rb +2091 -2088
- metadata +5 -3
- data/test/test_generic_spreadsheet.rb +0 -237
data/test/test_roo.rb
CHANGED
@@ -1,2088 +1,2091 @@
|
|
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
|
-
|
13
|
-
#TODO
|
14
|
-
# Look at formulas in excel - does not work with date/time
|
15
|
-
|
16
|
-
# Dump warnings that come from the test to open files
|
17
|
-
# with the wrong spreadsheet class
|
18
|
-
#STDERR.reopen "/dev/null","w"
|
19
|
-
|
20
|
-
require 'test_helper'
|
21
|
-
require 'stringio'
|
22
|
-
|
23
|
-
class TestRoo < Minitest::Test
|
24
|
-
|
25
|
-
OPENOFFICE = true # do OpenOffice-Spreadsheet Tests? (.ods files)
|
26
|
-
EXCELX = true # do Excelx Tests? (.xlsx files)
|
27
|
-
LIBREOFFICE = true # do LibreOffice tests? (.ods files)
|
28
|
-
CSV = true # do CSV tests? (.csv files)
|
29
|
-
|
30
|
-
FORMATS = [
|
31
|
-
:excelx,
|
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
|
-
oo.sheets
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
oo.sheets
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
assert_equal
|
106
|
-
assert_equal
|
107
|
-
assert_equal
|
108
|
-
assert_equal
|
109
|
-
assert_equal
|
110
|
-
assert_equal
|
111
|
-
assert_equal
|
112
|
-
assert_equal
|
113
|
-
assert_equal
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
assert_equal
|
121
|
-
assert_equal
|
122
|
-
assert_equal
|
123
|
-
assert_equal
|
124
|
-
assert_equal
|
125
|
-
assert_equal
|
126
|
-
assert_equal
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
assert_equal "tata", oo.cell(6,
|
147
|
-
assert_equal "tata", oo.cell('
|
148
|
-
|
149
|
-
|
150
|
-
assert_equal "
|
151
|
-
assert_equal "
|
152
|
-
assert_equal "
|
153
|
-
assert_equal "thisisc8", oo.cell(8,
|
154
|
-
assert_equal "thisisc8", oo.cell('
|
155
|
-
assert_equal "
|
156
|
-
assert_equal "
|
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
|
-
assert_raises(RangeError) { oo.
|
182
|
-
assert_raises(RangeError) { oo.
|
183
|
-
assert_raises(RangeError) { oo.
|
184
|
-
assert_raises(RangeError) { oo.
|
185
|
-
assert_raises(RangeError) { oo.
|
186
|
-
assert_raises(RangeError) { oo.
|
187
|
-
assert_raises(RangeError) { oo.
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
assert_equal
|
204
|
-
assert_equal 10, oo.cell('
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
assert_equal
|
215
|
-
assert_equal
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
assert_equal 1, oo.cell('A',
|
225
|
-
assert_equal
|
226
|
-
assert_equal 1, oo.cell('C',
|
227
|
-
assert_equal 1, oo.cell('A',
|
228
|
-
assert_equal
|
229
|
-
assert_equal 1, oo.cell('C',
|
230
|
-
assert_equal
|
231
|
-
assert_equal
|
232
|
-
assert_equal
|
233
|
-
assert_equal
|
234
|
-
assert_equal
|
235
|
-
assert_equal
|
236
|
-
assert_equal
|
237
|
-
|
238
|
-
|
239
|
-
assert_equal
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
assert_equal "1:string",oo.cell(
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
assert_equal "1
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
assert_equal "
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
assert_equal "0.01:
|
265
|
-
assert_equal "0.01:
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
assert_equal
|
277
|
-
assert_equal
|
278
|
-
assert_equal
|
279
|
-
assert_equal
|
280
|
-
assert_equal
|
281
|
-
assert_equal
|
282
|
-
|
283
|
-
assert_equal
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
oo.
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
oo.
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
assert_equal
|
314
|
-
assert_equal
|
315
|
-
assert_equal
|
316
|
-
assert_equal
|
317
|
-
assert_equal
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
#
|
323
|
-
#
|
324
|
-
|
325
|
-
#[
|
326
|
-
#
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
oo.
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
oo.
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
assert_equal
|
350
|
-
|
351
|
-
|
352
|
-
assert_equal
|
353
|
-
|
354
|
-
|
355
|
-
assert_equal
|
356
|
-
|
357
|
-
|
358
|
-
assert_equal 7, oo.
|
359
|
-
|
360
|
-
|
361
|
-
assert_equal
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
assert_equal
|
372
|
-
assert_equal
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
assert oo.empty?('
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
assert_equal '
|
413
|
-
assert_equal
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
assert_equal 'B', oo.cell('
|
421
|
-
assert_equal 'B', oo.cell('
|
422
|
-
assert_equal 'B', oo.cell('
|
423
|
-
assert_equal 'B', oo.cell('
|
424
|
-
assert_equal 'B', oo.cell('
|
425
|
-
assert_equal 'B', oo.cell('
|
426
|
-
assert_equal 'B', oo.cell('
|
427
|
-
assert_equal 'B', oo.cell('
|
428
|
-
assert_equal 'B', oo.cell('
|
429
|
-
assert_equal 'B', oo.cell('
|
430
|
-
assert_equal 'B', oo.cell('
|
431
|
-
assert_equal 'B', oo.cell('
|
432
|
-
|
433
|
-
|
434
|
-
assert_equal
|
435
|
-
|
436
|
-
|
437
|
-
assert_equal
|
438
|
-
|
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
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
assert_equal "
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
oo.
|
485
|
-
assert_equal 'Einflüsse der neuen Theologie in "de gereformeerde Kerken van Nederland"',
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
assert_equal :date, oo.celltype('
|
499
|
-
assert_equal :date, oo.celltype('
|
500
|
-
assert_equal
|
501
|
-
assert_equal
|
502
|
-
assert_equal
|
503
|
-
assert_equal Date.new(2007,11,21), oo.cell('
|
504
|
-
assert_equal Date.new(2007,11,21), oo.cell('
|
505
|
-
assert_equal
|
506
|
-
assert_equal
|
507
|
-
assert_equal
|
508
|
-
assert_equal :float, oo.celltype('
|
509
|
-
assert_equal :float, oo.celltype('
|
510
|
-
assert_equal
|
511
|
-
assert_equal
|
512
|
-
assert_equal
|
513
|
-
assert_equal 42, oo.cell('
|
514
|
-
assert_equal 42, oo.cell('
|
515
|
-
assert_equal
|
516
|
-
assert_equal
|
517
|
-
assert_equal
|
518
|
-
assert_equal :string, oo.celltype('
|
519
|
-
assert_equal :string, oo.celltype('
|
520
|
-
assert_equal
|
521
|
-
assert_equal
|
522
|
-
assert_equal
|
523
|
-
assert_equal "ABC", oo.cell('
|
524
|
-
assert_equal "ABC", oo.cell('
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
assert_equal
|
537
|
-
assert_equal
|
538
|
-
|
539
|
-
assert_equal :date, oo.celltype('
|
540
|
-
assert_equal :date, oo.celltype('
|
541
|
-
assert_equal
|
542
|
-
assert_equal
|
543
|
-
assert_equal
|
544
|
-
assert_equal Date.new(2007,11,21), oo.cell('
|
545
|
-
assert_equal Date.new(2007,11,21), oo.cell('
|
546
|
-
assert_equal
|
547
|
-
assert_equal
|
548
|
-
assert_equal
|
549
|
-
assert_equal :float, oo.celltype('
|
550
|
-
assert_equal :float, oo.celltype('
|
551
|
-
assert_equal
|
552
|
-
assert_equal
|
553
|
-
assert_equal
|
554
|
-
assert_equal 42, oo.cell('
|
555
|
-
assert_equal 42, oo.cell('
|
556
|
-
assert_equal
|
557
|
-
assert_equal
|
558
|
-
assert_equal
|
559
|
-
assert_equal :string, oo.celltype('
|
560
|
-
assert_equal :string, oo.celltype('
|
561
|
-
assert_equal
|
562
|
-
assert_equal
|
563
|
-
assert_equal
|
564
|
-
assert_equal "ABC", oo.cell('
|
565
|
-
assert_equal "ABC", oo.cell('
|
566
|
-
oo.
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
assert_equal
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
rec
|
623
|
-
|
624
|
-
assert_equal
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
"
|
643
|
-
"
|
644
|
-
"
|
645
|
-
"
|
646
|
-
|
647
|
-
"
|
648
|
-
"
|
649
|
-
|
650
|
-
"
|
651
|
-
"
|
652
|
-
"
|
653
|
-
"
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
"
|
672
|
-
"
|
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
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
assert_equal
|
725
|
-
assert_equal '
|
726
|
-
assert_equal
|
727
|
-
|
728
|
-
|
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
|
-
|
757
|
-
|
758
|
-
assert_equal
|
759
|
-
assert_equal
|
760
|
-
assert_equal
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
"
|
779
|
-
"
|
780
|
-
"
|
781
|
-
"
|
782
|
-
"
|
783
|
-
" First
|
784
|
-
" Last
|
785
|
-
"
|
786
|
-
"
|
787
|
-
"
|
788
|
-
" First
|
789
|
-
" Last
|
790
|
-
"
|
791
|
-
"
|
792
|
-
"
|
793
|
-
" First
|
794
|
-
" Last
|
795
|
-
"
|
796
|
-
"
|
797
|
-
"
|
798
|
-
" First
|
799
|
-
" Last
|
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
|
-
assert_nil oo.
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
assert_equal
|
868
|
-
assert_equal
|
869
|
-
assert_equal
|
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
|
-
|
914
|
-
|
915
|
-
|
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
|
-
cell.attributes['
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
assert_raises(TypeError
|
980
|
-
|
981
|
-
|
982
|
-
assert_raises(TypeError) { Roo::
|
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
|
-
|
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
|
-
assert_equal nil, oo.
|
1058
|
-
assert_equal nil, oo.
|
1059
|
-
assert_equal nil, oo.
|
1060
|
-
assert_equal nil, oo.
|
1061
|
-
assert_equal nil, oo.
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
assert_equal
|
1076
|
-
assert_equal
|
1077
|
-
assert_equal
|
1078
|
-
assert_equal
|
1079
|
-
assert_equal
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
assert_equal [:numeric_or_formula, "
|
1089
|
-
assert_equal [:numeric_or_formula, "
|
1090
|
-
assert_equal :
|
1091
|
-
|
1092
|
-
assert_equal "
|
1093
|
-
assert_equal
|
1094
|
-
|
1095
|
-
assert_equal "
|
1096
|
-
assert_equal "
|
1097
|
-
|
1098
|
-
|
1099
|
-
assert_equal "
|
1100
|
-
|
1101
|
-
assert_equal "
|
1102
|
-
assert_equal "
|
1103
|
-
assert_equal
|
1104
|
-
assert_equal
|
1105
|
-
assert_equal
|
1106
|
-
assert_equal
|
1107
|
-
assert_equal :
|
1108
|
-
assert_equal
|
1109
|
-
assert_equal
|
1110
|
-
assert_equal :
|
1111
|
-
assert_equal
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
assert_equal
|
1123
|
-
assert_kind_of
|
1124
|
-
|
1125
|
-
assert_equal
|
1126
|
-
|
1127
|
-
assert_equal
|
1128
|
-
assert_equal
|
1129
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('a',
|
1130
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('b',
|
1131
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('c',
|
1132
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('a',
|
1133
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('b',
|
1134
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('c',
|
1135
|
-
assert_equal
|
1136
|
-
assert_equal
|
1137
|
-
assert_equal
|
1138
|
-
assert_equal Date.new(1961,11,21), oo.cell('a',
|
1139
|
-
assert_equal Date.new(1961,11,21), oo.cell('b',
|
1140
|
-
assert_equal Date.new(1961,11,21), oo.cell('c',
|
1141
|
-
assert_equal
|
1142
|
-
assert_equal
|
1143
|
-
assert_equal
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
assert_equal "
|
1153
|
-
assert_equal "
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
assert_equal "
|
1165
|
-
assert_equal "
|
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
|
-
assert_equal false, oo.font(
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
assert_equal false, oo.font(
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
assert_equal false, oo.font(
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
assert_equal true, oo.font(
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
assert_equal
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
assert_equal
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
assert_equal true,
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
assert_equal
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
assert_equal
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
assert_equal false,
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
assert_equal [
|
1250
|
-
assert_equal [nil, nil, nil, nil, nil, nil], oo.row(
|
1251
|
-
assert_equal [Date
|
1252
|
-
|
1253
|
-
assert_equal [
|
1254
|
-
assert_equal [Date.new(2007,5,7),
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
assert_equal ["
|
1268
|
-
assert_equal ["
|
1269
|
-
assert_equal ["
|
1270
|
-
|
1271
|
-
assert_equal [
|
1272
|
-
assert_equal [
|
1273
|
-
|
1274
|
-
assert_equal [nil, nil, nil], oo.column(
|
1275
|
-
assert_equal [
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
assert_equal
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
assert_equal
|
1305
|
-
assert_equal
|
1306
|
-
assert_equal
|
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
|
-
row,
|
1354
|
-
assert_equal
|
1355
|
-
|
1356
|
-
row,col = oo.label('
|
1357
|
-
assert_equal '
|
1358
|
-
|
1359
|
-
row,col = oo.label('
|
1360
|
-
assert_equal '
|
1361
|
-
|
1362
|
-
row,col = oo.label('
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
row
|
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
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
assert_equal
|
1408
|
-
|
1409
|
-
row,col = oo.label('
|
1410
|
-
assert_equal '
|
1411
|
-
|
1412
|
-
row,col = oo.label('
|
1413
|
-
assert_equal '
|
1414
|
-
|
1415
|
-
row,col = oo.label('
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
row
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
assert_equal
|
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
|
-
|
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
|
-
# mit
|
1583
|
-
#
|
1584
|
-
#
|
1585
|
-
#
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
assert_equal [
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
assert_equal(
|
1609
|
-
assert_equal(
|
1610
|
-
assert_equal(
|
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
|
-
assert_nil oo.comment('b',
|
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
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
assert_equal oo2.cell('
|
1731
|
-
assert_equal oo2.cell('
|
1732
|
-
assert_equal oo2.cell('
|
1733
|
-
assert_equal oo2.cell('
|
1734
|
-
assert_equal oo2.cell('
|
1735
|
-
assert_equal oo2.cell('
|
1736
|
-
assert_equal oo2.cell('
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1747
|
-
assert_equal
|
1748
|
-
assert_equal
|
1749
|
-
assert_equal
|
1750
|
-
assert_equal
|
1751
|
-
assert_equal
|
1752
|
-
assert_equal
|
1753
|
-
assert_equal
|
1754
|
-
assert_equal
|
1755
|
-
assert_equal
|
1756
|
-
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1761
|
-
#
|
1762
|
-
# ex.
|
1763
|
-
#
|
1764
|
-
#
|
1765
|
-
#
|
1766
|
-
#
|
1767
|
-
#
|
1768
|
-
#
|
1769
|
-
#
|
1770
|
-
#
|
1771
|
-
#
|
1772
|
-
#
|
1773
|
-
#
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1781
|
-
|
1782
|
-
|
1783
|
-
|
1784
|
-
|
1785
|
-
|
1786
|
-
|
1787
|
-
|
1788
|
-
|
1789
|
-
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1793
|
-
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
|
1799
|
-
|
1800
|
-
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
#
|
1809
|
-
#
|
1810
|
-
#
|
1811
|
-
#
|
1812
|
-
# p "serverthread
|
1813
|
-
#
|
1814
|
-
#
|
1815
|
-
#
|
1816
|
-
#
|
1817
|
-
#
|
1818
|
-
#
|
1819
|
-
#
|
1820
|
-
# proxy.
|
1821
|
-
# proxy.add_method('
|
1822
|
-
# proxy.add_method('
|
1823
|
-
# proxy.add_method('
|
1824
|
-
# proxy.add_method('
|
1825
|
-
# proxy.add_method('
|
1826
|
-
# proxy.add_method('
|
1827
|
-
|
1828
|
-
#
|
1829
|
-
#
|
1830
|
-
|
1831
|
-
|
1832
|
-
#
|
1833
|
-
#
|
1834
|
-
|
1835
|
-
# assert_equal
|
1836
|
-
# assert_equal
|
1837
|
-
# assert_equal
|
1838
|
-
# assert_equal
|
1839
|
-
#
|
1840
|
-
#
|
1841
|
-
#
|
1842
|
-
#
|
1843
|
-
#
|
1844
|
-
#
|
1845
|
-
# puts "
|
1846
|
-
#
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
1850
|
-
|
1851
|
-
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1855
|
-
|
1856
|
-
|
1857
|
-
|
1858
|
-
|
1859
|
-
|
1860
|
-
|
1861
|
-
|
1862
|
-
end
|
1863
|
-
|
1864
|
-
|
1865
|
-
|
1866
|
-
|
1867
|
-
|
1868
|
-
|
1869
|
-
#
|
1870
|
-
#
|
1871
|
-
# b,z = split_coord(arg[
|
1872
|
-
#
|
1873
|
-
#
|
1874
|
-
#
|
1875
|
-
#
|
1876
|
-
#
|
1877
|
-
#
|
1878
|
-
#
|
1879
|
-
#
|
1880
|
-
#
|
1881
|
-
#
|
1882
|
-
|
1883
|
-
#
|
1884
|
-
#
|
1885
|
-
|
1886
|
-
#
|
1887
|
-
#
|
1888
|
-
#
|
1889
|
-
#
|
1890
|
-
# s.set
|
1891
|
-
#
|
1892
|
-
#
|
1893
|
-
#
|
1894
|
-
#
|
1895
|
-
|
1896
|
-
#
|
1897
|
-
#
|
1898
|
-
|
1899
|
-
#
|
1900
|
-
#
|
1901
|
-
#
|
1902
|
-
#
|
1903
|
-
|
1904
|
-
#
|
1905
|
-
#
|
1906
|
-
|
1907
|
-
#
|
1908
|
-
#
|
1909
|
-
# s.
|
1910
|
-
# s.
|
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
|
-
|
1962
|
-
|
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
|
-
|
2023
|
-
|
2024
|
-
|
2025
|
-
|
2026
|
-
|
2027
|
-
|
2028
|
-
|
2029
|
-
|
2030
|
-
|
2031
|
-
|
2032
|
-
|
2033
|
-
|
2034
|
-
|
2035
|
-
|
2036
|
-
|
2037
|
-
|
2038
|
-
|
2039
|
-
|
2040
|
-
|
2041
|
-
|
2042
|
-
|
2043
|
-
|
2044
|
-
|
2045
|
-
|
2046
|
-
|
2047
|
-
|
2048
|
-
|
2049
|
-
|
2050
|
-
|
2051
|
-
|
2052
|
-
|
2053
|
-
|
2054
|
-
|
2055
|
-
|
2056
|
-
|
2057
|
-
|
2058
|
-
|
2059
|
-
|
2060
|
-
|
2061
|
-
|
2062
|
-
|
2063
|
-
|
2064
|
-
|
2065
|
-
|
2066
|
-
|
2067
|
-
|
2068
|
-
|
2069
|
-
|
2070
|
-
|
2071
|
-
|
2072
|
-
|
2073
|
-
|
2074
|
-
|
2075
|
-
|
2076
|
-
|
2077
|
-
|
2078
|
-
|
2079
|
-
|
2080
|
-
|
2081
|
-
|
2082
|
-
|
2083
|
-
|
2084
|
-
|
2085
|
-
|
2086
|
-
|
2087
|
-
|
2088
|
-
|
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
|
+
|
13
|
+
#TODO
|
14
|
+
# Look at formulas in excel - does not work with date/time
|
15
|
+
|
16
|
+
# Dump warnings that come from the test to open files
|
17
|
+
# with the wrong spreadsheet class
|
18
|
+
#STDERR.reopen "/dev/null","w"
|
19
|
+
|
20
|
+
require 'test_helper'
|
21
|
+
require 'stringio'
|
22
|
+
|
23
|
+
class TestRoo < Minitest::Test
|
24
|
+
|
25
|
+
OPENOFFICE = true # do OpenOffice-Spreadsheet Tests? (.ods files)
|
26
|
+
EXCELX = true # do Excelx Tests? (.xlsx files)
|
27
|
+
LIBREOFFICE = true # do LibreOffice tests? (.ods files)
|
28
|
+
CSV = true # do CSV tests? (.csv files)
|
29
|
+
|
30
|
+
FORMATS = [
|
31
|
+
:excelx,
|
32
|
+
:excelxm,
|
33
|
+
:openoffice,
|
34
|
+
:libreoffice
|
35
|
+
]
|
36
|
+
|
37
|
+
ONLINE = false
|
38
|
+
LONG_RUN = false
|
39
|
+
|
40
|
+
def fixture_filename(name, format)
|
41
|
+
case format
|
42
|
+
when :excelx
|
43
|
+
"#{name}.xlsx"
|
44
|
+
when :excelxm
|
45
|
+
"#{name}.xlsm"
|
46
|
+
when :openoffice, :libreoffice
|
47
|
+
"#{name}.ods"
|
48
|
+
else
|
49
|
+
raise ArgumentError, "unexpected format #{format}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# call a block of code for each spreadsheet type
|
54
|
+
# and yield a reference to the roo object
|
55
|
+
def with_each_spreadsheet(options)
|
56
|
+
if options[:format]
|
57
|
+
formats = Array(options[:format])
|
58
|
+
invalid_formats = formats - FORMATS
|
59
|
+
unless invalid_formats.empty?
|
60
|
+
raise "invalid spreadsheet types: #{invalid_formats.join(', ')}"
|
61
|
+
end
|
62
|
+
else
|
63
|
+
formats = FORMATS
|
64
|
+
end
|
65
|
+
formats.each do |format|
|
66
|
+
begin
|
67
|
+
yield Roo::Spreadsheet.open(File.join(TESTDIR,
|
68
|
+
fixture_filename(options[:name], format)))
|
69
|
+
rescue => e
|
70
|
+
raise e, "#{e.message} for #{format}", e.backtrace unless options[:ignore_errors]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_sheets_csv
|
76
|
+
if CSV
|
77
|
+
oo = Roo::CSV.new(File.join(TESTDIR,'numbers1.csv'))
|
78
|
+
assert_equal ["default"], oo.sheets
|
79
|
+
assert_raises(RangeError) { oo.default_sheet = "no_sheet" }
|
80
|
+
assert_raises(TypeError) { oo.default_sheet = [1,2,3] }
|
81
|
+
oo.sheets.each { |sh|
|
82
|
+
oo.default_sheet = sh
|
83
|
+
assert_equal sh, oo.default_sheet
|
84
|
+
}
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_sheets
|
89
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
90
|
+
assert_equal ["Tabelle1","Name of Sheet 2","Sheet3","Sheet4","Sheet5"], oo.sheets
|
91
|
+
assert_raises(RangeError) { oo.default_sheet = "no_sheet" }
|
92
|
+
assert_raises(TypeError) { oo.default_sheet = [1,2,3] }
|
93
|
+
oo.sheets.each { |sh|
|
94
|
+
oo.default_sheet = sh
|
95
|
+
assert_equal sh, oo.default_sheet
|
96
|
+
}
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_cells
|
101
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
102
|
+
# warum ist Auswaehlen erstes sheet hier nicht
|
103
|
+
# mehr drin?
|
104
|
+
oo.default_sheet = oo.sheets.first
|
105
|
+
assert_equal 1, oo.cell(1,1)
|
106
|
+
assert_equal 2, oo.cell(1,2)
|
107
|
+
assert_equal 3, oo.cell(1,3)
|
108
|
+
assert_equal 4, oo.cell(1,4)
|
109
|
+
assert_equal 5, oo.cell(2,1)
|
110
|
+
assert_equal 6, oo.cell(2,2)
|
111
|
+
assert_equal 7, oo.cell(2,3)
|
112
|
+
assert_equal 8, oo.cell(2,4)
|
113
|
+
assert_equal 9, oo.cell(2,5)
|
114
|
+
assert_equal "test", oo.cell(2,6)
|
115
|
+
assert_equal :string, oo.celltype(2,6)
|
116
|
+
assert_equal 11, oo.cell(2,7)
|
117
|
+
unless oo.kind_of? Roo::CSV
|
118
|
+
assert_equal :float, oo.celltype(2,7)
|
119
|
+
end
|
120
|
+
assert_equal 10, oo.cell(4,1)
|
121
|
+
assert_equal 11, oo.cell(4,2)
|
122
|
+
assert_equal 12, oo.cell(4,3)
|
123
|
+
assert_equal 13, oo.cell(4,4)
|
124
|
+
assert_equal 14, oo.cell(4,5)
|
125
|
+
assert_equal 10, oo.cell(4,'A')
|
126
|
+
assert_equal 11, oo.cell(4,'B')
|
127
|
+
assert_equal 12, oo.cell(4,'C')
|
128
|
+
assert_equal 13, oo.cell(4,'D')
|
129
|
+
assert_equal 14, oo.cell(4,'E')
|
130
|
+
unless oo.kind_of? Roo::CSV
|
131
|
+
assert_equal :date, oo.celltype(5,1)
|
132
|
+
assert_equal Date.new(1961,11,21), oo.cell(5,1)
|
133
|
+
assert_equal "1961-11-21", oo.cell(5,1).to_s
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_celltype
|
139
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
140
|
+
assert_equal :string, oo.celltype(2,6)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_cell_address
|
145
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
146
|
+
assert_equal "tata", oo.cell(6,1)
|
147
|
+
assert_equal "tata", oo.cell(6,'A')
|
148
|
+
assert_equal "tata", oo.cell('A',6)
|
149
|
+
assert_equal "tata", oo.cell(6,'a')
|
150
|
+
assert_equal "tata", oo.cell('a',6)
|
151
|
+
assert_raises(ArgumentError) { assert_equal "tata", oo.cell('a','f') }
|
152
|
+
assert_raises(ArgumentError) { assert_equal "tata", oo.cell('f','a') }
|
153
|
+
assert_equal "thisisc8", oo.cell(8,3)
|
154
|
+
assert_equal "thisisc8", oo.cell(8,'C')
|
155
|
+
assert_equal "thisisc8", oo.cell('C',8)
|
156
|
+
assert_equal "thisisc8", oo.cell(8,'c')
|
157
|
+
assert_equal "thisisc8", oo.cell('c',8)
|
158
|
+
assert_equal "thisisd9", oo.cell('d',9)
|
159
|
+
assert_equal "thisisa11", oo.cell('a',11)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def test_office_version
|
164
|
+
with_each_spreadsheet(:name=>'numbers1', :format=>:openoffice) do |oo|
|
165
|
+
assert_equal "1.0", oo.officeversion
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
def test_libre_office
|
170
|
+
if LIBREOFFICE
|
171
|
+
oo = Roo::LibreOffice.new(File.join(TESTDIR, "numbers1.ods"))
|
172
|
+
oo.default_sheet = oo.sheets.first
|
173
|
+
assert_equal 41, oo.cell('a',12)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def test_sheetname
|
178
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
179
|
+
oo.default_sheet = "Name of Sheet 2"
|
180
|
+
assert_equal 'I am sheet 2', oo.cell('C',5)
|
181
|
+
assert_raises(RangeError) { oo.default_sheet = "non existing sheet name" }
|
182
|
+
assert_raises(RangeError) { oo.default_sheet = "non existing sheet name" }
|
183
|
+
assert_raises(RangeError) { oo.cell('C',5,"non existing sheet name")}
|
184
|
+
assert_raises(RangeError) { oo.celltype('C',5,"non existing sheet name")}
|
185
|
+
assert_raises(RangeError) { oo.empty?('C',5,"non existing sheet name")}
|
186
|
+
assert_raises(RangeError) { oo.formula?('C',5,"non existing sheet name")}
|
187
|
+
assert_raises(RangeError) { oo.formula('C',5,"non existing sheet name")}
|
188
|
+
assert_raises(RangeError) { oo.set('C',5,42,"non existing sheet name")}
|
189
|
+
assert_raises(RangeError) { oo.formulas("non existing sheet name")}
|
190
|
+
assert_raises(RangeError) { oo.to_yaml({},1,1,1,1,"non existing sheet name")}
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
def test_argument_error
|
195
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
196
|
+
oo.default_sheet = "Tabelle1"
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
def test_bug_contiguous_cells
|
201
|
+
with_each_spreadsheet(:name=>'numbers1', :format=>:openoffice) do |oo|
|
202
|
+
oo.default_sheet = "Sheet4"
|
203
|
+
assert_equal Date.new(2007,06,16), oo.cell('a',1)
|
204
|
+
assert_equal 10, oo.cell('b',1)
|
205
|
+
assert_equal 10, oo.cell('c',1)
|
206
|
+
assert_equal 10, oo.cell('d',1)
|
207
|
+
assert_equal 10, oo.cell('e',1)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
def test_bug_italo_ve
|
212
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
213
|
+
oo.default_sheet = "Sheet5"
|
214
|
+
assert_equal 1, oo.cell('A',1)
|
215
|
+
assert_equal 5, oo.cell('b',1)
|
216
|
+
assert_equal 5, oo.cell('c',1)
|
217
|
+
assert_equal 2, oo.cell('a',2)
|
218
|
+
assert_equal 3, oo.cell('a',3)
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
def test_italo_table
|
223
|
+
with_each_spreadsheet(:name=>'simple_spreadsheet_from_italo', :format=>:openoffice) do |oo|
|
224
|
+
assert_equal '1', oo.cell('A',1)
|
225
|
+
assert_equal '1', oo.cell('B',1)
|
226
|
+
assert_equal '1', oo.cell('C',1)
|
227
|
+
assert_equal 1, oo.cell('A',2).to_i
|
228
|
+
assert_equal 2, oo.cell('B',2).to_i
|
229
|
+
assert_equal 1, oo.cell('C',2).to_i
|
230
|
+
assert_equal 1, oo.cell('A',3)
|
231
|
+
assert_equal 3, oo.cell('B',3)
|
232
|
+
assert_equal 1, oo.cell('C',3)
|
233
|
+
assert_equal 'A', oo.cell('A',4)
|
234
|
+
assert_equal 'A', oo.cell('B',4)
|
235
|
+
assert_equal 'A', oo.cell('C',4)
|
236
|
+
assert_equal 0.01, oo.cell('A',5)
|
237
|
+
assert_equal 0.01, oo.cell('B',5)
|
238
|
+
assert_equal 0.01, oo.cell('C',5)
|
239
|
+
assert_equal 0.03, oo.cell('a',5)+oo.cell('b',5)+oo.cell('c',5)
|
240
|
+
|
241
|
+
# Cells values in row 1:
|
242
|
+
assert_equal "1:string", oo.cell(1, 1)+":"+oo.celltype(1, 1).to_s
|
243
|
+
assert_equal "1:string",oo.cell(1, 2)+":"+oo.celltype(1, 2).to_s
|
244
|
+
assert_equal "1:string",oo.cell(1, 3)+":"+oo.celltype(1, 3).to_s
|
245
|
+
|
246
|
+
# Cells values in row 2:
|
247
|
+
assert_equal "1:string",oo.cell(2, 1)+":"+oo.celltype(2, 1).to_s
|
248
|
+
assert_equal "2:string",oo.cell(2, 2)+":"+oo.celltype(2, 2).to_s
|
249
|
+
assert_equal "1:string",oo.cell(2, 3)+":"+oo.celltype(2, 3).to_s
|
250
|
+
|
251
|
+
# Cells values in row 3:
|
252
|
+
assert_equal "1.0:float",oo.cell(3, 1).to_s+":"+oo.celltype(3, 1).to_s
|
253
|
+
assert_equal "3.0:float",oo.cell(3, 2).to_s+":"+oo.celltype(3, 2).to_s
|
254
|
+
assert_equal "1.0:float",oo.cell(3, 3).to_s+":"+oo.celltype(3, 3).to_s
|
255
|
+
|
256
|
+
# Cells values in row 4:
|
257
|
+
assert_equal "A:string",oo.cell(4, 1)+":"+oo.celltype(4, 1).to_s
|
258
|
+
assert_equal "A:string",oo.cell(4, 2)+":"+oo.celltype(4, 2).to_s
|
259
|
+
assert_equal "A:string",oo.cell(4, 3)+":"+oo.celltype(4, 3).to_s
|
260
|
+
|
261
|
+
# Cells values in row 5:
|
262
|
+
if oo.class == Roo::OpenOffice
|
263
|
+
assert_equal "0.01:percentage",oo.cell(5, 1).to_s+":"+oo.celltype(5, 1).to_s
|
264
|
+
assert_equal "0.01:percentage",oo.cell(5, 2).to_s+":"+oo.celltype(5, 2).to_s
|
265
|
+
assert_equal "0.01:percentage",oo.cell(5, 3).to_s+":"+oo.celltype(5, 3).to_s
|
266
|
+
else
|
267
|
+
assert_equal "0.01:float",oo.cell(5, 1).to_s+":"+oo.celltype(5, 1).to_s
|
268
|
+
assert_equal "0.01:float",oo.cell(5, 2).to_s+":"+oo.celltype(5, 2).to_s
|
269
|
+
assert_equal "0.01:float",oo.cell(5, 3).to_s+":"+oo.celltype(5, 3).to_s
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
def test_formula_openoffice
|
275
|
+
with_each_spreadsheet(:name=>'formula', :format=>:openoffice) do |oo|
|
276
|
+
assert_equal 1, oo.cell('A',1)
|
277
|
+
assert_equal 2, oo.cell('A',2)
|
278
|
+
assert_equal 3, oo.cell('A',3)
|
279
|
+
assert_equal 4, oo.cell('A',4)
|
280
|
+
assert_equal 5, oo.cell('A',5)
|
281
|
+
assert_equal 6, oo.cell('A',6)
|
282
|
+
assert_equal 21, oo.cell('A',7)
|
283
|
+
assert_equal :formula, oo.celltype('A',7)
|
284
|
+
assert_equal "=[Sheet2.A1]", oo.formula('C',7)
|
285
|
+
assert_nil oo.formula('A',6)
|
286
|
+
assert_equal [[7, 1, "=SUM([.A1:.A6])"],
|
287
|
+
[7, 2, "=SUM([.$A$1:.B6])"],
|
288
|
+
[7, 3, "=[Sheet2.A1]"],
|
289
|
+
[8, 2, "=SUM([.$A$1:.B7])"],
|
290
|
+
], oo.formulas(oo.sheets.first)
|
291
|
+
|
292
|
+
# setting a cell
|
293
|
+
oo.set('A',15, 41)
|
294
|
+
assert_equal 41, oo.cell('A',15)
|
295
|
+
oo.set('A',16, "41")
|
296
|
+
assert_equal "41", oo.cell('A',16)
|
297
|
+
oo.set('A',17, 42.5)
|
298
|
+
assert_equal 42.5, oo.cell('A',17)
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
def test_header_with_brackets_excelx
|
303
|
+
with_each_spreadsheet(:name => 'advanced_header', :format => :openoffice) do |oo|
|
304
|
+
parsed_head = oo.parse(:headers => true)
|
305
|
+
assert_equal "Date(yyyy-mm-dd)", oo.cell('A',1)
|
306
|
+
assert_equal parsed_head[0].keys, ["Date(yyyy-mm-dd)"]
|
307
|
+
assert_equal parsed_head[0].values, ["Date(yyyy-mm-dd)"]
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
def test_formula_excelx
|
312
|
+
with_each_spreadsheet(:name=>'formula', :format=>:excelx) do |oo|
|
313
|
+
assert_equal 1, oo.cell('A',1)
|
314
|
+
assert_equal 2, oo.cell('A',2)
|
315
|
+
assert_equal 3, oo.cell('A',3)
|
316
|
+
assert_equal 4, oo.cell('A',4)
|
317
|
+
assert_equal 5, oo.cell('A',5)
|
318
|
+
assert_equal 6, oo.cell('A',6)
|
319
|
+
assert_equal 21, oo.cell('A',7)
|
320
|
+
assert_equal :formula, oo.celltype('A',7)
|
321
|
+
#steht nicht in Datei, oder?
|
322
|
+
#nein, diesen Bezug habe ich nur in der OpenOffice-Datei
|
323
|
+
#assert_equal "=[Sheet2.A1]", oo.formula('C',7)
|
324
|
+
assert_nil oo.formula('A',6)
|
325
|
+
# assert_equal [[7, 1, "=SUM([.A1:.A6])"],
|
326
|
+
# [7, 2, "=SUM([.$A$1:.B6])"],
|
327
|
+
#[7, 3, "=[Sheet2.A1]"],
|
328
|
+
#[8, 2, "=SUM([.$A$1:.B7])"],
|
329
|
+
#], oo.formulas(oo.sheets.first)
|
330
|
+
assert_equal [[7, 1, 'SUM(A1:A6)'],
|
331
|
+
[7, 2, 'SUM($A$1:B6)'],
|
332
|
+
# [7, 3, "=[Sheet2.A1]"],
|
333
|
+
# [8, 2, "=SUM([.$A$1:.B7])"],
|
334
|
+
], oo.formulas(oo.sheets.first)
|
335
|
+
|
336
|
+
# setting a cell
|
337
|
+
oo.set('A',15, 41)
|
338
|
+
assert_equal 41, oo.cell('A',15)
|
339
|
+
oo.set('A',16, "41")
|
340
|
+
assert_equal "41", oo.cell('A',16)
|
341
|
+
oo.set('A',17, 42.5)
|
342
|
+
assert_equal 42.5, oo.cell('A',17)
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
def test_borders_sheets
|
347
|
+
with_each_spreadsheet(:name=>'borders') do |oo|
|
348
|
+
oo.default_sheet = oo.sheets[1]
|
349
|
+
assert_equal 6, oo.first_row
|
350
|
+
assert_equal 11, oo.last_row
|
351
|
+
assert_equal 4, oo.first_column
|
352
|
+
assert_equal 8, oo.last_column
|
353
|
+
|
354
|
+
oo.default_sheet = oo.sheets.first
|
355
|
+
assert_equal 5, oo.first_row
|
356
|
+
assert_equal 10, oo.last_row
|
357
|
+
assert_equal 3, oo.first_column
|
358
|
+
assert_equal 7, oo.last_column
|
359
|
+
|
360
|
+
oo.default_sheet = oo.sheets[2]
|
361
|
+
assert_equal 7, oo.first_row
|
362
|
+
assert_equal 12, oo.last_row
|
363
|
+
assert_equal 5, oo.first_column
|
364
|
+
assert_equal 9, oo.last_column
|
365
|
+
end
|
366
|
+
end
|
367
|
+
|
368
|
+
def test_only_one_sheet
|
369
|
+
with_each_spreadsheet(:name=>'only_one_sheet') do |oo|
|
370
|
+
assert_equal 42, oo.cell('B',4)
|
371
|
+
assert_equal 43, oo.cell('C',4)
|
372
|
+
assert_equal 44, oo.cell('D',4)
|
373
|
+
oo.default_sheet = oo.sheets.first
|
374
|
+
assert_equal 42, oo.cell('B',4)
|
375
|
+
assert_equal 43, oo.cell('C',4)
|
376
|
+
assert_equal 44, oo.cell('D',4)
|
377
|
+
end
|
378
|
+
end
|
379
|
+
|
380
|
+
def test_openoffice_download_uri_and_zipped
|
381
|
+
if OPENOFFICE
|
382
|
+
if ONLINE
|
383
|
+
url = 'http://spazioinwind.libero.it/s2/rata.ods.zip'
|
384
|
+
sheet = Roo::OpenOffice.new(url, packed: :zip)
|
385
|
+
#has been changed: assert_equal 'ist "e" im Nenner von H(s)', sheet.cell('b', 5)
|
386
|
+
assert_in_delta 0.001, 505.14, sheet.cell('c', 33).to_f
|
387
|
+
end
|
388
|
+
end
|
389
|
+
end
|
390
|
+
|
391
|
+
def test_openoffice_zipped
|
392
|
+
if OPENOFFICE
|
393
|
+
oo = Roo::OpenOffice.new(File.join(TESTDIR,"bode-v1.ods.zip"), packed: :zip)
|
394
|
+
assert oo
|
395
|
+
assert_equal 'ist "e" im Nenner von H(s)', oo.cell('b', 5)
|
396
|
+
end
|
397
|
+
end
|
398
|
+
|
399
|
+
def test_bug_ric
|
400
|
+
with_each_spreadsheet(:name=>'ric', :format=>:openoffice) do |oo|
|
401
|
+
assert oo.empty?('A',1)
|
402
|
+
assert oo.empty?('B',1)
|
403
|
+
assert oo.empty?('C',1)
|
404
|
+
assert oo.empty?('D',1)
|
405
|
+
expected = 1
|
406
|
+
letter = 'e'
|
407
|
+
while letter <= 'u'
|
408
|
+
assert_equal expected, oo.cell(letter,1)
|
409
|
+
letter.succ!
|
410
|
+
expected += 1
|
411
|
+
end
|
412
|
+
assert_equal 'J', oo.cell('v',1)
|
413
|
+
assert_equal 'P', oo.cell('w',1)
|
414
|
+
assert_equal 'B', oo.cell('x',1)
|
415
|
+
assert_equal 'All', oo.cell('y',1)
|
416
|
+
assert_equal 0, oo.cell('a',2)
|
417
|
+
assert oo.empty?('b',2)
|
418
|
+
assert oo.empty?('c',2)
|
419
|
+
assert oo.empty?('d',2)
|
420
|
+
assert_equal 'B', oo.cell('e',2)
|
421
|
+
assert_equal 'B', oo.cell('f',2)
|
422
|
+
assert_equal 'B', oo.cell('g',2)
|
423
|
+
assert_equal 'B', oo.cell('h',2)
|
424
|
+
assert_equal 'B', oo.cell('i',2)
|
425
|
+
assert_equal 'B', oo.cell('j',2)
|
426
|
+
assert_equal 'B', oo.cell('k',2)
|
427
|
+
assert_equal 'B', oo.cell('l',2)
|
428
|
+
assert_equal 'B', oo.cell('m',2)
|
429
|
+
assert_equal 'B', oo.cell('n',2)
|
430
|
+
assert_equal 'B', oo.cell('o',2)
|
431
|
+
assert_equal 'B', oo.cell('p',2)
|
432
|
+
assert_equal 'B', oo.cell('q',2)
|
433
|
+
assert_equal 'B', oo.cell('r',2)
|
434
|
+
assert_equal 'B', oo.cell('s',2)
|
435
|
+
assert oo.empty?('t',2)
|
436
|
+
assert oo.empty?('u',2)
|
437
|
+
assert_equal 0 , oo.cell('v',2)
|
438
|
+
assert_equal 0 , oo.cell('w',2)
|
439
|
+
assert_equal 15 , oo.cell('x',2)
|
440
|
+
assert_equal 15 , oo.cell('y',2)
|
441
|
+
end
|
442
|
+
end
|
443
|
+
|
444
|
+
def test_mehrteilig
|
445
|
+
with_each_spreadsheet(:name=>'Bibelbund1', :format=>:openoffice) do |oo|
|
446
|
+
assert_equal "Tagebuch des Sekret\303\244rs. Letzte Tagung 15./16.11.75 Schweiz", oo.cell(45,'A')
|
447
|
+
end
|
448
|
+
#if EXCELX
|
449
|
+
# #Datei gibt es noch nicht
|
450
|
+
# oo = Roo::Excelx.new(File.join(TESTDIR,"Bibelbund1.xlsx"))
|
451
|
+
# oo.default_sheet = oo.sheets.first
|
452
|
+
# assert_equal "Tagebuch des Sekret\303\244rs. Letzte Tagung 15./16.11.75 Schweiz", oo.cell(45,'A')
|
453
|
+
#end
|
454
|
+
end
|
455
|
+
|
456
|
+
# "/tmp/xxxx" darf man unter Windows nicht verwenden, weil das nicht erkannt
|
457
|
+
# wird.
|
458
|
+
# Besser: Methode um temporaeres Dir. portabel zu bestimmen
|
459
|
+
def test_huge_document_to_csv
|
460
|
+
if LONG_RUN
|
461
|
+
with_each_spreadsheet(:name=>'Bibelbund', :format=>[
|
462
|
+
:openoffice,
|
463
|
+
:excelx
|
464
|
+
# Google hier nicht, weil Google-Spreadsheets nicht so gross werden
|
465
|
+
# duerfen
|
466
|
+
]) do |oo|
|
467
|
+
Dir.mktmpdir do |tempdir|
|
468
|
+
assert_equal "Tagebuch des Sekret\303\244rs. Letzte Tagung 15./16.11.75 Schweiz", oo.cell(45,'A')
|
469
|
+
assert_equal "Tagebuch des Sekret\303\244rs. Nachrichten aus Chile", oo.cell(46,'A')
|
470
|
+
assert_equal "Tagebuch aus Chile Juli 1977", oo.cell(55,'A')
|
471
|
+
assert oo.to_csv(File.join(tempdir,"Bibelbund.csv"))
|
472
|
+
assert File.exists?(File.join(tempdir,"Bibelbund.csv"))
|
473
|
+
assert_equal "", file_diff(File.join(TESTDIR, "Bibelbund.csv"), File.join(tempdir,"Bibelbund.csv")),
|
474
|
+
"error in class #{oo.class}"
|
475
|
+
#end
|
476
|
+
end
|
477
|
+
end
|
478
|
+
end
|
479
|
+
end
|
480
|
+
|
481
|
+
def test_bug_quotes_excelx
|
482
|
+
if LONG_RUN
|
483
|
+
with_each_spreadsheet(:name=>'Bibelbund', :format=>[:openoffice, :excelx]) do |oo|
|
484
|
+
oo.default_sheet = oo.sheets.first
|
485
|
+
assert_equal 'Einflüsse der neuen Theologie in "de gereformeerde Kerken van Nederland"',
|
486
|
+
oo.cell('a',76)
|
487
|
+
oo.to_csv("csv#{$$}")
|
488
|
+
assert_equal 'Einflüsse der neuen Theologie in "de gereformeerde Kerken van Nederland"',
|
489
|
+
oo.cell('a',78)
|
490
|
+
File.delete_if_exist("csv#{$$}")
|
491
|
+
end
|
492
|
+
end
|
493
|
+
end
|
494
|
+
|
495
|
+
def test_bug_mehrere_datum
|
496
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
497
|
+
oo.default_sheet = 'Sheet5'
|
498
|
+
assert_equal :date, oo.celltype('A',4)
|
499
|
+
assert_equal :date, oo.celltype('B',4)
|
500
|
+
assert_equal :date, oo.celltype('C',4)
|
501
|
+
assert_equal :date, oo.celltype('D',4)
|
502
|
+
assert_equal :date, oo.celltype('E',4)
|
503
|
+
assert_equal Date.new(2007,11,21), oo.cell('A',4)
|
504
|
+
assert_equal Date.new(2007,11,21), oo.cell('B',4)
|
505
|
+
assert_equal Date.new(2007,11,21), oo.cell('C',4)
|
506
|
+
assert_equal Date.new(2007,11,21), oo.cell('D',4)
|
507
|
+
assert_equal Date.new(2007,11,21), oo.cell('E',4)
|
508
|
+
assert_equal :float, oo.celltype('A',5)
|
509
|
+
assert_equal :float, oo.celltype('B',5)
|
510
|
+
assert_equal :float, oo.celltype('C',5)
|
511
|
+
assert_equal :float, oo.celltype('D',5)
|
512
|
+
assert_equal :float, oo.celltype('E',5)
|
513
|
+
assert_equal 42, oo.cell('A',5)
|
514
|
+
assert_equal 42, oo.cell('B',5)
|
515
|
+
assert_equal 42, oo.cell('C',5)
|
516
|
+
assert_equal 42, oo.cell('D',5)
|
517
|
+
assert_equal 42, oo.cell('E',5)
|
518
|
+
assert_equal :string, oo.celltype('A',6)
|
519
|
+
assert_equal :string, oo.celltype('B',6)
|
520
|
+
assert_equal :string, oo.celltype('C',6)
|
521
|
+
assert_equal :string, oo.celltype('D',6)
|
522
|
+
assert_equal :string, oo.celltype('E',6)
|
523
|
+
assert_equal "ABC", oo.cell('A',6)
|
524
|
+
assert_equal "ABC", oo.cell('B',6)
|
525
|
+
assert_equal "ABC", oo.cell('C',6)
|
526
|
+
assert_equal "ABC", oo.cell('D',6)
|
527
|
+
assert_equal "ABC", oo.cell('E',6)
|
528
|
+
end
|
529
|
+
end
|
530
|
+
|
531
|
+
def test_multiple_sheets
|
532
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
533
|
+
2.times do
|
534
|
+
oo.default_sheet = "Tabelle1"
|
535
|
+
assert_equal 1, oo.cell(1,1)
|
536
|
+
assert_equal 1, oo.cell(1,1,"Tabelle1")
|
537
|
+
assert_equal "I am sheet 2", oo.cell('C',5,"Name of Sheet 2")
|
538
|
+
sheetname = 'Sheet5'
|
539
|
+
assert_equal :date, oo.celltype('A',4,sheetname)
|
540
|
+
assert_equal :date, oo.celltype('B',4,sheetname)
|
541
|
+
assert_equal :date, oo.celltype('C',4,sheetname)
|
542
|
+
assert_equal :date, oo.celltype('D',4,sheetname)
|
543
|
+
assert_equal :date, oo.celltype('E',4,sheetname)
|
544
|
+
assert_equal Date.new(2007,11,21), oo.cell('A',4,sheetname)
|
545
|
+
assert_equal Date.new(2007,11,21), oo.cell('B',4,sheetname)
|
546
|
+
assert_equal Date.new(2007,11,21), oo.cell('C',4,sheetname)
|
547
|
+
assert_equal Date.new(2007,11,21), oo.cell('D',4,sheetname)
|
548
|
+
assert_equal Date.new(2007,11,21), oo.cell('E',4,sheetname)
|
549
|
+
assert_equal :float, oo.celltype('A',5,sheetname)
|
550
|
+
assert_equal :float, oo.celltype('B',5,sheetname)
|
551
|
+
assert_equal :float, oo.celltype('C',5,sheetname)
|
552
|
+
assert_equal :float, oo.celltype('D',5,sheetname)
|
553
|
+
assert_equal :float, oo.celltype('E',5,sheetname)
|
554
|
+
assert_equal 42, oo.cell('A',5,sheetname)
|
555
|
+
assert_equal 42, oo.cell('B',5,sheetname)
|
556
|
+
assert_equal 42, oo.cell('C',5,sheetname)
|
557
|
+
assert_equal 42, oo.cell('D',5,sheetname)
|
558
|
+
assert_equal 42, oo.cell('E',5,sheetname)
|
559
|
+
assert_equal :string, oo.celltype('A',6,sheetname)
|
560
|
+
assert_equal :string, oo.celltype('B',6,sheetname)
|
561
|
+
assert_equal :string, oo.celltype('C',6,sheetname)
|
562
|
+
assert_equal :string, oo.celltype('D',6,sheetname)
|
563
|
+
assert_equal :string, oo.celltype('E',6,sheetname)
|
564
|
+
assert_equal "ABC", oo.cell('A',6,sheetname)
|
565
|
+
assert_equal "ABC", oo.cell('B',6,sheetname)
|
566
|
+
assert_equal "ABC", oo.cell('C',6,sheetname)
|
567
|
+
assert_equal "ABC", oo.cell('D',6,sheetname)
|
568
|
+
assert_equal "ABC", oo.cell('E',6,sheetname)
|
569
|
+
oo.reload
|
570
|
+
end
|
571
|
+
end
|
572
|
+
end
|
573
|
+
|
574
|
+
|
575
|
+
def test_bug_empty_sheet
|
576
|
+
with_each_spreadsheet(:name=>'formula', :format=>[:openoffice, :excelx]) do |oo|
|
577
|
+
oo.default_sheet = 'Sheet3' # is an empty sheet
|
578
|
+
Dir.mktmpdir do |tempdir|
|
579
|
+
oo.to_csv(File.join(tempdir,"emptysheet.csv"))
|
580
|
+
assert_equal "", `cat #{File.join(tempdir,"emptysheet.csv")}`
|
581
|
+
end
|
582
|
+
end
|
583
|
+
end
|
584
|
+
|
585
|
+
def test_find_by_row_huge_document
|
586
|
+
if LONG_RUN
|
587
|
+
with_each_spreadsheet(:name=>'Bibelbund', :format=>[:openoffice, :excelx]) do |oo|
|
588
|
+
oo.default_sheet = oo.sheets.first
|
589
|
+
rec = oo.find 20
|
590
|
+
assert rec
|
591
|
+
# assert_equal "Brief aus dem Sekretariat", rec[0]
|
592
|
+
#p rec
|
593
|
+
assert_equal "Brief aus dem Sekretariat", rec[0]['TITEL']
|
594
|
+
rec = oo.find 22
|
595
|
+
assert rec
|
596
|
+
# assert_equal "Brief aus dem Skretariat. Tagung in Amberg/Opf.",rec[0]
|
597
|
+
assert_equal "Brief aus dem Skretariat. Tagung in Amberg/Opf.",rec[0]['TITEL']
|
598
|
+
end
|
599
|
+
end
|
600
|
+
end
|
601
|
+
|
602
|
+
def test_find_by_row
|
603
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
604
|
+
oo.header_line = nil
|
605
|
+
rec = oo.find 16
|
606
|
+
assert rec
|
607
|
+
assert_nil oo.header_line
|
608
|
+
# keine Headerlines in diesem Beispiel definiert
|
609
|
+
assert_equal "einundvierzig", rec[0]
|
610
|
+
#assert_equal false, rec
|
611
|
+
rec = oo.find 15
|
612
|
+
assert rec
|
613
|
+
assert_equal 41,rec[0]
|
614
|
+
end
|
615
|
+
end
|
616
|
+
|
617
|
+
def test_find_by_row_if_header_line_is_not_nil
|
618
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
619
|
+
oo.header_line = 2
|
620
|
+
refute_nil oo.header_line
|
621
|
+
rec = oo.find 1
|
622
|
+
assert rec
|
623
|
+
assert_equal 5, rec[0]
|
624
|
+
assert_equal 6, rec[1]
|
625
|
+
rec = oo.find 15
|
626
|
+
assert rec
|
627
|
+
assert_equal "einundvierzig", rec[0]
|
628
|
+
end
|
629
|
+
end
|
630
|
+
|
631
|
+
def test_find_by_conditions
|
632
|
+
if LONG_RUN
|
633
|
+
with_each_spreadsheet(:name=>'Bibelbund', :format=>[:openoffice,
|
634
|
+
:excelx]) do |oo|
|
635
|
+
#-----------------------------------------------------------------
|
636
|
+
zeilen = oo.find(:all, :conditions => {
|
637
|
+
'TITEL' => 'Brief aus dem Sekretariat'
|
638
|
+
}
|
639
|
+
)
|
640
|
+
assert_equal 2, zeilen.size
|
641
|
+
assert_equal [{"VERFASSER"=>"Almassy, Annelene von",
|
642
|
+
"INTERNET"=>nil,
|
643
|
+
"SEITE"=>316.0,
|
644
|
+
"KENNUNG"=>"Aus dem Bibelbund",
|
645
|
+
"OBJEKT"=>"Bibel+Gem",
|
646
|
+
"PC"=>"#C:\\Bibelbund\\reprint\\BuG1982-3.pdf#",
|
647
|
+
"NUMMER"=>"1982-3",
|
648
|
+
"TITEL"=>"Brief aus dem Sekretariat"},
|
649
|
+
{"VERFASSER"=>"Almassy, Annelene von",
|
650
|
+
"INTERNET"=>nil,
|
651
|
+
"SEITE"=>222.0,
|
652
|
+
"KENNUNG"=>"Aus dem Bibelbund",
|
653
|
+
"OBJEKT"=>"Bibel+Gem",
|
654
|
+
"PC"=>"#C:\\Bibelbund\\reprint\\BuG1983-2.pdf#",
|
655
|
+
"NUMMER"=>"1983-2",
|
656
|
+
"TITEL"=>"Brief aus dem Sekretariat"}] , zeilen
|
657
|
+
|
658
|
+
#----------------------------------------------------------
|
659
|
+
zeilen = oo.find(:all,
|
660
|
+
:conditions => { 'VERFASSER' => 'Almassy, Annelene von' }
|
661
|
+
)
|
662
|
+
assert_equal 13, zeilen.size
|
663
|
+
#----------------------------------------------------------
|
664
|
+
zeilen = oo.find(:all, :conditions => {
|
665
|
+
'TITEL' => 'Brief aus dem Sekretariat',
|
666
|
+
'VERFASSER' => 'Almassy, Annelene von',
|
667
|
+
}
|
668
|
+
)
|
669
|
+
assert_equal 2, zeilen.size
|
670
|
+
assert_equal [{"VERFASSER"=>"Almassy, Annelene von",
|
671
|
+
"INTERNET"=>nil,
|
672
|
+
"SEITE"=>316.0,
|
673
|
+
"KENNUNG"=>"Aus dem Bibelbund",
|
674
|
+
"OBJEKT"=>"Bibel+Gem",
|
675
|
+
"PC"=>"#C:\\Bibelbund\\reprint\\BuG1982-3.pdf#",
|
676
|
+
"NUMMER"=>"1982-3",
|
677
|
+
"TITEL"=>"Brief aus dem Sekretariat"},
|
678
|
+
{"VERFASSER"=>"Almassy, Annelene von",
|
679
|
+
"INTERNET"=>nil,
|
680
|
+
"SEITE"=>222.0,
|
681
|
+
"KENNUNG"=>"Aus dem Bibelbund",
|
682
|
+
"OBJEKT"=>"Bibel+Gem",
|
683
|
+
"PC"=>"#C:\\Bibelbund\\reprint\\BuG1983-2.pdf#",
|
684
|
+
"NUMMER"=>"1983-2",
|
685
|
+
"TITEL"=>"Brief aus dem Sekretariat"}] , zeilen
|
686
|
+
|
687
|
+
# Result as an array
|
688
|
+
zeilen = oo.find(:all,
|
689
|
+
:conditions => {
|
690
|
+
'TITEL' => 'Brief aus dem Sekretariat',
|
691
|
+
'VERFASSER' => 'Almassy, Annelene von',
|
692
|
+
}, :array => true)
|
693
|
+
assert_equal 2, zeilen.size
|
694
|
+
assert_equal [
|
695
|
+
[
|
696
|
+
"Brief aus dem Sekretariat",
|
697
|
+
"Almassy, Annelene von",
|
698
|
+
"Bibel+Gem",
|
699
|
+
"1982-3",
|
700
|
+
316.0,
|
701
|
+
nil,
|
702
|
+
"#C:\\Bibelbund\\reprint\\BuG1982-3.pdf#",
|
703
|
+
"Aus dem Bibelbund",
|
704
|
+
],
|
705
|
+
[
|
706
|
+
"Brief aus dem Sekretariat",
|
707
|
+
"Almassy, Annelene von",
|
708
|
+
"Bibel+Gem",
|
709
|
+
"1983-2",
|
710
|
+
222.0,
|
711
|
+
nil,
|
712
|
+
"#C:\\Bibelbund\\reprint\\BuG1983-2.pdf#",
|
713
|
+
"Aus dem Bibelbund",
|
714
|
+
]] , zeilen
|
715
|
+
end
|
716
|
+
end
|
717
|
+
end
|
718
|
+
|
719
|
+
|
720
|
+
#TODO: temporaerer Test
|
721
|
+
def test_seiten_als_date
|
722
|
+
if LONG_RUN
|
723
|
+
with_each_spreadsheet(:name=>'Bibelbund', :format=>:excelx) do |oo|
|
724
|
+
assert_equal 'Bericht aus dem Sekretariat', oo.cell(13,1)
|
725
|
+
assert_equal '1981-4', oo.cell(13,'D')
|
726
|
+
assert_equal String, oo.excelx_type(13,'E')[1].class
|
727
|
+
assert_equal [:numeric_or_formula,"General"], oo.excelx_type(13,'E')
|
728
|
+
assert_equal '428', oo.excelx_value(13,'E')
|
729
|
+
assert_equal 428.0, oo.cell(13,'E')
|
730
|
+
end
|
731
|
+
end
|
732
|
+
end
|
733
|
+
|
734
|
+
def test_column
|
735
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
736
|
+
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)]
|
737
|
+
assert_equal expected, oo.column(1)
|
738
|
+
assert_equal expected, oo.column('a')
|
739
|
+
end
|
740
|
+
end
|
741
|
+
|
742
|
+
def test_column_huge_document
|
743
|
+
if LONG_RUN
|
744
|
+
with_each_spreadsheet(:name=>'Bibelbund', :format=>[:openoffice,
|
745
|
+
:excelx]) do |oo|
|
746
|
+
oo.default_sheet = oo.sheets.first
|
747
|
+
assert_equal 3735, oo.column('a').size
|
748
|
+
#assert_equal 499, oo.column('a').size
|
749
|
+
end
|
750
|
+
end
|
751
|
+
end
|
752
|
+
|
753
|
+
def test_simple_spreadsheet_find_by_condition
|
754
|
+
with_each_spreadsheet(:name=>'simple_spreadsheet') do |oo|
|
755
|
+
oo.header_line = 3
|
756
|
+
# oo.date_format = '%m/%d/%Y' if oo.class == Google
|
757
|
+
erg = oo.find(:all, :conditions => {'Comment' => 'Task 1'})
|
758
|
+
assert_equal Date.new(2007,05,07), erg[1]['Date']
|
759
|
+
assert_equal 10.75 , erg[1]['Start time']
|
760
|
+
assert_equal 12.50 , erg[1]['End time']
|
761
|
+
assert_equal 0 , erg[1]['Pause']
|
762
|
+
assert_equal 1.75 , erg[1]['Sum']
|
763
|
+
assert_equal "Task 1" , erg[1]['Comment']
|
764
|
+
end
|
765
|
+
end
|
766
|
+
|
767
|
+
def get_extension(oo)
|
768
|
+
case oo
|
769
|
+
when Roo::OpenOffice
|
770
|
+
".ods"
|
771
|
+
when Roo::Excelx
|
772
|
+
".xlsx"
|
773
|
+
end
|
774
|
+
end
|
775
|
+
|
776
|
+
def test_info
|
777
|
+
expected_templ = "File: numbers1%s\n"+
|
778
|
+
"Number of sheets: 5\n"+
|
779
|
+
"Sheets: Tabelle1, Name of Sheet 2, Sheet3, Sheet4, Sheet5\n"+
|
780
|
+
"Sheet 1:\n"+
|
781
|
+
" First row: 1\n"+
|
782
|
+
" Last row: 18\n"+
|
783
|
+
" First column: A\n"+
|
784
|
+
" Last column: G\n"+
|
785
|
+
"Sheet 2:\n"+
|
786
|
+
" First row: 5\n"+
|
787
|
+
" Last row: 14\n"+
|
788
|
+
" First column: B\n"+
|
789
|
+
" Last column: E\n"+
|
790
|
+
"Sheet 3:\n"+
|
791
|
+
" First row: 1\n"+
|
792
|
+
" Last row: 1\n"+
|
793
|
+
" First column: A\n"+
|
794
|
+
" Last column: BA\n"+
|
795
|
+
"Sheet 4:\n"+
|
796
|
+
" First row: 1\n"+
|
797
|
+
" Last row: 1\n"+
|
798
|
+
" First column: A\n"+
|
799
|
+
" Last column: E\n"+
|
800
|
+
"Sheet 5:\n"+
|
801
|
+
" First row: 1\n"+
|
802
|
+
" Last row: 6\n"+
|
803
|
+
" First column: A\n"+
|
804
|
+
" Last column: E"
|
805
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
806
|
+
ext = get_extension(oo)
|
807
|
+
expected = sprintf(expected_templ,ext)
|
808
|
+
begin
|
809
|
+
if oo.class == Google
|
810
|
+
assert_equal expected.gsub(/numbers1/,key_of("numbers1")), oo.info
|
811
|
+
else
|
812
|
+
assert_equal expected, oo.info
|
813
|
+
end
|
814
|
+
rescue NameError
|
815
|
+
#
|
816
|
+
end
|
817
|
+
end
|
818
|
+
end
|
819
|
+
|
820
|
+
def test_info_doesnt_set_default_sheet
|
821
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
822
|
+
oo.default_sheet = 'Sheet3'
|
823
|
+
oo.info
|
824
|
+
assert_equal 'Sheet3', oo.default_sheet
|
825
|
+
end
|
826
|
+
end
|
827
|
+
|
828
|
+
def test_should_raise_file_not_found_error
|
829
|
+
if OPENOFFICE
|
830
|
+
assert_raises(IOError) {
|
831
|
+
Roo::OpenOffice.new(File.join('testnichtvorhanden','Bibelbund.ods'))
|
832
|
+
}
|
833
|
+
end
|
834
|
+
if EXCELX
|
835
|
+
assert_raises(IOError) {
|
836
|
+
Roo::Excelx.new(File.join('testnichtvorhanden','Bibelbund.xlsx'))
|
837
|
+
}
|
838
|
+
end
|
839
|
+
end
|
840
|
+
|
841
|
+
def test_bug_bbu
|
842
|
+
with_each_spreadsheet(:name=>'bbu', :format=>[:openoffice, :excelx]) do |oo|
|
843
|
+
assert_equal "File: bbu#{get_extension(oo)}
|
844
|
+
Number of sheets: 3
|
845
|
+
Sheets: 2007_12, Tabelle2, Tabelle3
|
846
|
+
Sheet 1:
|
847
|
+
First row: 1
|
848
|
+
Last row: 4
|
849
|
+
First column: A
|
850
|
+
Last column: F
|
851
|
+
Sheet 2:
|
852
|
+
- empty -
|
853
|
+
Sheet 3:
|
854
|
+
- empty -", oo.info
|
855
|
+
|
856
|
+
oo.default_sheet = oo.sheets[1] # empty sheet
|
857
|
+
assert_nil oo.first_row
|
858
|
+
assert_nil oo.last_row
|
859
|
+
assert_nil oo.first_column
|
860
|
+
assert_nil oo.last_column
|
861
|
+
end
|
862
|
+
end
|
863
|
+
|
864
|
+
|
865
|
+
def test_bug_time_nil
|
866
|
+
with_each_spreadsheet(:name=>'time-test') do |oo|
|
867
|
+
assert_equal 12*3600+13*60+14, oo.cell('B',1) # 12:13:14 (secs since midnight)
|
868
|
+
assert_equal :time, oo.celltype('B',1)
|
869
|
+
assert_equal 15*3600+16*60, oo.cell('C',1) # 15:16 (secs since midnight)
|
870
|
+
assert_equal :time, oo.celltype('C',1)
|
871
|
+
assert_equal 23*3600, oo.cell('D',1) # 23:00 (secs since midnight)
|
872
|
+
assert_equal :time, oo.celltype('D',1)
|
873
|
+
end
|
874
|
+
end
|
875
|
+
|
876
|
+
def test_date_time_to_csv
|
877
|
+
with_each_spreadsheet(:name=>'time-test') do |oo|
|
878
|
+
Dir.mktmpdir do |tempdir|
|
879
|
+
csv_output = File.join(tempdir,'time_test.csv')
|
880
|
+
assert oo.to_csv(csv_output)
|
881
|
+
assert File.exists?(csv_output)
|
882
|
+
assert_equal "", `diff --strip-trailing-cr #{TESTDIR}/time-test.csv #{csv_output}`
|
883
|
+
# --strip-trailing-cr is needed because the test-file use 0A and
|
884
|
+
# the test on an windows box generates 0D 0A as line endings
|
885
|
+
end
|
886
|
+
end
|
887
|
+
end
|
888
|
+
|
889
|
+
def test_boolean_to_csv
|
890
|
+
with_each_spreadsheet(:name=>'boolean') do |oo|
|
891
|
+
Dir.mktmpdir do |tempdir|
|
892
|
+
csv_output = File.join(tempdir,'boolean.csv')
|
893
|
+
assert oo.to_csv(csv_output)
|
894
|
+
assert File.exists?(csv_output)
|
895
|
+
assert_equal "", `diff --strip-trailing-cr #{TESTDIR}/boolean.csv #{csv_output}`
|
896
|
+
# --strip-trailing-cr is needed because the test-file use 0A and
|
897
|
+
# the test on an windows box generates 0D 0A as line endings
|
898
|
+
end
|
899
|
+
end
|
900
|
+
end
|
901
|
+
def test_link_to_csv
|
902
|
+
with_each_spreadsheet(:name=>'link',:format=>:excelx) do |oo|
|
903
|
+
Dir.mktmpdir do |tempdir|
|
904
|
+
csv_output = File.join(tempdir,'link.csv')
|
905
|
+
assert oo.to_csv(csv_output)
|
906
|
+
assert File.exists?(csv_output)
|
907
|
+
assert_equal "", `diff --strip-trailing-cr #{TESTDIR}/link.csv #{csv_output}`
|
908
|
+
# --strip-trailing-cr is needed because the test-file use 0A and
|
909
|
+
# the test on an windows box generates 0D 0A as line endings
|
910
|
+
end
|
911
|
+
end
|
912
|
+
end
|
913
|
+
def test_date_time_yaml
|
914
|
+
with_each_spreadsheet(:name=>'time-test') do |oo|
|
915
|
+
expected =
|
916
|
+
"--- \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"
|
917
|
+
assert_equal expected, oo.to_yaml
|
918
|
+
end
|
919
|
+
end
|
920
|
+
|
921
|
+
# Erstellt eine Liste aller Zellen im Spreadsheet. Dies ist nötig, weil ein einfacher
|
922
|
+
# Textvergleich des XML-Outputs nicht funktioniert, da xml-builder die Attribute
|
923
|
+
# nicht immer in der gleichen Reihenfolge erzeugt.
|
924
|
+
def init_all_cells(oo,sheet)
|
925
|
+
all = []
|
926
|
+
oo.first_row(sheet).upto(oo.last_row(sheet)) do |row|
|
927
|
+
oo.first_column(sheet).upto(oo.last_column(sheet)) do |col|
|
928
|
+
unless oo.empty?(row,col,sheet)
|
929
|
+
all << {:row => row.to_s,
|
930
|
+
:column => col.to_s,
|
931
|
+
:content => oo.cell(row,col,sheet).to_s,
|
932
|
+
:type => oo.celltype(row,col,sheet).to_s,
|
933
|
+
}
|
934
|
+
end
|
935
|
+
end
|
936
|
+
end
|
937
|
+
all
|
938
|
+
end
|
939
|
+
|
940
|
+
def test_to_xml
|
941
|
+
with_each_spreadsheet(:name=>'numbers1', :encoding => 'utf8') do |oo|
|
942
|
+
skip if defined? JRUBY_VERSION
|
943
|
+
oo.to_xml
|
944
|
+
sheetname = oo.sheets.first
|
945
|
+
doc = Nokogiri::XML(oo.to_xml)
|
946
|
+
sheet_count = 0
|
947
|
+
doc.xpath('//spreadsheet/sheet').each {|tmpelem|
|
948
|
+
sheet_count += 1
|
949
|
+
}
|
950
|
+
assert_equal 5, sheet_count
|
951
|
+
doc.xpath('//spreadsheet/sheet').each { |xml_sheet|
|
952
|
+
all_cells = init_all_cells(oo, sheetname)
|
953
|
+
x = 0
|
954
|
+
assert_equal sheetname, xml_sheet.attributes['name'].value
|
955
|
+
xml_sheet.children.each {|cell|
|
956
|
+
if cell.attributes['name']
|
957
|
+
expected = [all_cells[x][:row],
|
958
|
+
all_cells[x][:column],
|
959
|
+
all_cells[x][:content],
|
960
|
+
all_cells[x][:type],
|
961
|
+
]
|
962
|
+
result = [
|
963
|
+
cell.attributes['row'],
|
964
|
+
cell.attributes['column'],
|
965
|
+
cell.content,
|
966
|
+
cell.attributes['type'],
|
967
|
+
]
|
968
|
+
assert_equal expected, result
|
969
|
+
x += 1
|
970
|
+
end # if
|
971
|
+
} # end of sheet
|
972
|
+
sheetname = oo.sheets[oo.sheets.index(sheetname)+1]
|
973
|
+
}
|
974
|
+
end
|
975
|
+
end
|
976
|
+
|
977
|
+
def test_file_warning_default
|
978
|
+
if OPENOFFICE
|
979
|
+
assert_raises(TypeError, "test/files/numbers1.xls is not an openoffice spreadsheet") {
|
980
|
+
Roo::OpenOffice.new(File.join(TESTDIR,"numbers1.xls"))
|
981
|
+
}
|
982
|
+
assert_raises(TypeError) { Roo::OpenOffice.new(File.join(TESTDIR,"numbers1.xlsx")) }
|
983
|
+
end
|
984
|
+
if EXCELX
|
985
|
+
assert_raises(TypeError) { Roo::Excelx.new(File.join(TESTDIR,"numbers1.ods")) }
|
986
|
+
assert_raises(TypeError) { Roo::Excelx.new(File.join(TESTDIR,"numbers1.xls")) }
|
987
|
+
end
|
988
|
+
end
|
989
|
+
|
990
|
+
def test_file_warning_error
|
991
|
+
if OPENOFFICE
|
992
|
+
assert_raises(TypeError) {
|
993
|
+
Roo::OpenOffice.new(File.join(TESTDIR,"numbers1.xls"),
|
994
|
+
packed: false,
|
995
|
+
file_warning: :error
|
996
|
+
)
|
997
|
+
}
|
998
|
+
assert_raises(TypeError) {
|
999
|
+
Roo::OpenOffice.new(File.join(TESTDIR,"numbers1.xlsx"),
|
1000
|
+
packed: false,
|
1001
|
+
file_warning: :error)
|
1002
|
+
}
|
1003
|
+
end
|
1004
|
+
if EXCELX
|
1005
|
+
assert_raises(TypeError) {
|
1006
|
+
Roo::Excelx.new(File.join(TESTDIR,"numbers1.ods"),
|
1007
|
+
packed: false,
|
1008
|
+
file_warning: :error)
|
1009
|
+
}
|
1010
|
+
assert_raises(TypeError) {
|
1011
|
+
Roo::Excelx.new(File.join(TESTDIR,"numbers1.xls"),
|
1012
|
+
packed: false,
|
1013
|
+
file_warning: :error)
|
1014
|
+
}
|
1015
|
+
end
|
1016
|
+
end
|
1017
|
+
|
1018
|
+
def test_file_warning_warning
|
1019
|
+
if OPENOFFICE
|
1020
|
+
assert_raises(ArgumentError) {
|
1021
|
+
Roo::OpenOffice.new(File.join(TESTDIR,"numbers1.xlsx"),
|
1022
|
+
packed: false,
|
1023
|
+
file_warning: :warning)
|
1024
|
+
}
|
1025
|
+
end
|
1026
|
+
if EXCELX
|
1027
|
+
assert_raises(ArgumentError) {
|
1028
|
+
Roo::Excelx.new(File.join(TESTDIR,"numbers1.ods"),
|
1029
|
+
packed: false,
|
1030
|
+
file_warning: :warning)
|
1031
|
+
}
|
1032
|
+
end
|
1033
|
+
end
|
1034
|
+
|
1035
|
+
def test_file_warning_ignore
|
1036
|
+
if OPENOFFICE
|
1037
|
+
# Files, die eigentlich OpenOffice-
|
1038
|
+
# Files sind, aber die falsche Endung haben.
|
1039
|
+
# Es soll ohne Fehlermeldung oder Warnung
|
1040
|
+
# oder Abbruch die Datei geoffnet werden
|
1041
|
+
|
1042
|
+
# xlsx
|
1043
|
+
Roo::OpenOffice.new(File.join(TESTDIR,"type_openoffice.xlsx"),
|
1044
|
+
packed: false,
|
1045
|
+
file_warning: :ignore)
|
1046
|
+
end
|
1047
|
+
if EXCELX
|
1048
|
+
Roo::Excelx.new(File.join(TESTDIR,"type_excelx.ods"),
|
1049
|
+
packed: false,
|
1050
|
+
file_warning: :ignore)
|
1051
|
+
end
|
1052
|
+
end
|
1053
|
+
|
1054
|
+
def test_bug_to_xml_with_empty_sheets
|
1055
|
+
with_each_spreadsheet(:name=>'emptysheets', :format=>[:openoffice, :excelx]) do |oo|
|
1056
|
+
oo.sheets.each { |sheet|
|
1057
|
+
assert_equal nil, oo.first_row, "first_row not nil in sheet #{sheet}"
|
1058
|
+
assert_equal nil, oo.last_row, "last_row not nil in sheet #{sheet}"
|
1059
|
+
assert_equal nil, oo.first_column, "first_column not nil in sheet #{sheet}"
|
1060
|
+
assert_equal nil, oo.last_column, "last_column not nil in sheet #{sheet}"
|
1061
|
+
assert_equal nil, oo.first_row(sheet), "first_row not nil in sheet #{sheet}"
|
1062
|
+
assert_equal nil, oo.last_row(sheet), "last_row not nil in sheet #{sheet}"
|
1063
|
+
assert_equal nil, oo.first_column(sheet), "first_column not nil in sheet #{sheet}"
|
1064
|
+
assert_equal nil, oo.last_column(sheet), "last_column not nil in sheet #{sheet}"
|
1065
|
+
}
|
1066
|
+
oo.to_xml
|
1067
|
+
end
|
1068
|
+
end
|
1069
|
+
|
1070
|
+
def test_bug_simple_spreadsheet_time_bug
|
1071
|
+
# really a bug? are cells really of type time?
|
1072
|
+
# No! :float must be the correct type
|
1073
|
+
with_each_spreadsheet(:name=>'simple_spreadsheet', :format=>:excelx) do |oo|
|
1074
|
+
# puts oo.cell('B',5).to_s
|
1075
|
+
# assert_equal :time, oo.celltype('B',5)
|
1076
|
+
assert_equal :float, oo.celltype('B',5)
|
1077
|
+
assert_equal 10.75, oo.cell('B',5)
|
1078
|
+
assert_equal 12.50, oo.cell('C',5)
|
1079
|
+
assert_equal 0, oo.cell('D',5)
|
1080
|
+
assert_equal 1.75, oo.cell('E',5)
|
1081
|
+
assert_equal 'Task 1', oo.cell('F',5)
|
1082
|
+
assert_equal Date.new(2007,5,7), oo.cell('A',5)
|
1083
|
+
end
|
1084
|
+
end
|
1085
|
+
|
1086
|
+
def test_simple2_excelx
|
1087
|
+
with_each_spreadsheet(:name=>'simple_spreadsheet', :format=>:excelx) do |oo|
|
1088
|
+
assert_equal [:numeric_or_formula, "yyyy\\-mm\\-dd"], oo.excelx_type('A',4)
|
1089
|
+
assert_equal [:numeric_or_formula, "#,##0.00"], oo.excelx_type('B',4)
|
1090
|
+
assert_equal [:numeric_or_formula, "#,##0.00"], oo.excelx_type('c',4)
|
1091
|
+
assert_equal [:numeric_or_formula, "General"], oo.excelx_type('d',4)
|
1092
|
+
assert_equal [:numeric_or_formula, "General"], oo.excelx_type('e',4)
|
1093
|
+
assert_equal :string, oo.excelx_type('f',4)
|
1094
|
+
|
1095
|
+
assert_equal "39209", oo.excelx_value('a',4)
|
1096
|
+
assert_equal "yyyy\\-mm\\-dd", oo.excelx_format('a',4)
|
1097
|
+
assert_equal "9.25", oo.excelx_value('b',4)
|
1098
|
+
assert_equal "10.25", oo.excelx_value('c',4)
|
1099
|
+
assert_equal "0", oo.excelx_value('d',4)
|
1100
|
+
#... Sum-Spalte
|
1101
|
+
# assert_equal "Task 1", oo.excelx_value('f',4)
|
1102
|
+
assert_equal "Task 1", oo.cell('f',4)
|
1103
|
+
assert_equal Date.new(2007,05,07), oo.cell('a',4)
|
1104
|
+
assert_equal "9.25", oo.excelx_value('b',4)
|
1105
|
+
assert_equal "#,##0.00", oo.excelx_format('b',4)
|
1106
|
+
assert_equal 9.25, oo.cell('b',4)
|
1107
|
+
assert_equal :float, oo.celltype('b',4)
|
1108
|
+
assert_equal :float, oo.celltype('d',4)
|
1109
|
+
assert_equal 0, oo.cell('d',4)
|
1110
|
+
assert_equal :formula, oo.celltype('e',4)
|
1111
|
+
assert_equal 1, oo.cell('e',4)
|
1112
|
+
assert_equal 'C4-B4-D4', oo.formula('e',4)
|
1113
|
+
assert_equal :string, oo.celltype('f',4)
|
1114
|
+
assert_equal "Task 1", oo.cell('f',4)
|
1115
|
+
end
|
1116
|
+
end
|
1117
|
+
|
1118
|
+
def test_datetime
|
1119
|
+
with_each_spreadsheet(:name=>'datetime') do |oo|
|
1120
|
+
val = oo.cell('c',3)
|
1121
|
+
assert_equal :datetime, oo.celltype('c',3)
|
1122
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), val
|
1123
|
+
assert_kind_of DateTime, val
|
1124
|
+
val = oo.cell('a',1)
|
1125
|
+
assert_equal :date, oo.celltype('a',1)
|
1126
|
+
assert_kind_of Date, val
|
1127
|
+
assert_equal Date.new(1961,11,21), val
|
1128
|
+
assert_equal Date.new(1961,11,21), oo.cell('a',1)
|
1129
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('a',3)
|
1130
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('b',3)
|
1131
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('c',3)
|
1132
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('a',4)
|
1133
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('b',4)
|
1134
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('c',4)
|
1135
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('a',5)
|
1136
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('b',5)
|
1137
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('c',5)
|
1138
|
+
assert_equal Date.new(1961,11,21), oo.cell('a',6)
|
1139
|
+
assert_equal Date.new(1961,11,21), oo.cell('b',6)
|
1140
|
+
assert_equal Date.new(1961,11,21), oo.cell('c',6)
|
1141
|
+
assert_equal Date.new(1961,11,21), oo.cell('a',7)
|
1142
|
+
assert_equal Date.new(1961,11,21), oo.cell('b',7)
|
1143
|
+
assert_equal Date.new(1961,11,21), oo.cell('c',7)
|
1144
|
+
assert_equal DateTime.new(2013,11,5,11,45,00), oo.cell('a',8)
|
1145
|
+
assert_equal DateTime.new(2013,11,5,11,45,00), oo.cell('b',8)
|
1146
|
+
assert_equal DateTime.new(2013,11,5,11,45,00), oo.cell('c',8)
|
1147
|
+
end
|
1148
|
+
end
|
1149
|
+
|
1150
|
+
def test_cell_openoffice_html_escape
|
1151
|
+
with_each_spreadsheet(:name=>'html-escape', :format=>:openoffice) do |oo|
|
1152
|
+
assert_equal "'", oo.cell(1,1)
|
1153
|
+
assert_equal "&", oo.cell(2,1)
|
1154
|
+
assert_equal ">", oo.cell(3,1)
|
1155
|
+
assert_equal "<", oo.cell(4,1)
|
1156
|
+
assert_equal "`", oo.cell(5,1)
|
1157
|
+
# test_openoffice_zipped will catch issues with "
|
1158
|
+
end
|
1159
|
+
end
|
1160
|
+
|
1161
|
+
def test_cell_boolean
|
1162
|
+
with_each_spreadsheet(:name=>'boolean', :format=>[:openoffice, :excelx]) do |oo|
|
1163
|
+
if oo.class == Roo::Excelx
|
1164
|
+
assert_equal "TRUE", oo.cell(1,1), "failure in "+oo.class.to_s
|
1165
|
+
assert_equal "FALSE", oo.cell(2,1), "failure in "+oo.class.to_s
|
1166
|
+
else
|
1167
|
+
assert_equal "true", oo.cell(1,1), "failure in "+oo.class.to_s
|
1168
|
+
assert_equal "false", oo.cell(2,1), "failure in "+oo.class.to_s
|
1169
|
+
end
|
1170
|
+
end
|
1171
|
+
end
|
1172
|
+
|
1173
|
+
def test_cell_multiline
|
1174
|
+
with_each_spreadsheet(:name=>'paragraph', :format=>[:openoffice, :excelx]) do |oo|
|
1175
|
+
assert_equal "This is a test\nof a multiline\nCell", oo.cell(1,1)
|
1176
|
+
assert_equal "This is a test\n¶\nof a multiline\n\nCell", oo.cell(1,2)
|
1177
|
+
assert_equal "first p\n\nsecond p\n\nlast p", oo.cell(2,1)
|
1178
|
+
end
|
1179
|
+
end
|
1180
|
+
|
1181
|
+
def test_cell_styles
|
1182
|
+
# styles only valid in excel spreadsheets?
|
1183
|
+
# TODO: what todo with other spreadsheet types
|
1184
|
+
with_each_spreadsheet(:name=>'style', :format=>[# :openoffice,
|
1185
|
+
:excelx
|
1186
|
+
]) do |oo|
|
1187
|
+
# bold
|
1188
|
+
assert_equal true, oo.font(1,1).bold?
|
1189
|
+
assert_equal false, oo.font(1,1).italic?
|
1190
|
+
assert_equal false, oo.font(1,1).underline?
|
1191
|
+
|
1192
|
+
# italic
|
1193
|
+
assert_equal false, oo.font(2,1).bold?
|
1194
|
+
assert_equal true, oo.font(2,1).italic?
|
1195
|
+
assert_equal false, oo.font(2,1).underline?
|
1196
|
+
|
1197
|
+
# normal
|
1198
|
+
assert_equal false, oo.font(3,1).bold?
|
1199
|
+
assert_equal false, oo.font(3,1).italic?
|
1200
|
+
assert_equal false, oo.font(3,1).underline?
|
1201
|
+
|
1202
|
+
# underline
|
1203
|
+
assert_equal false, oo.font(4,1).bold?
|
1204
|
+
assert_equal false, oo.font(4,1).italic?
|
1205
|
+
assert_equal true, oo.font(4,1).underline?
|
1206
|
+
|
1207
|
+
# bold italic
|
1208
|
+
assert_equal true, oo.font(5,1).bold?
|
1209
|
+
assert_equal true, oo.font(5,1).italic?
|
1210
|
+
assert_equal false, oo.font(5,1).underline?
|
1211
|
+
|
1212
|
+
# bold underline
|
1213
|
+
assert_equal true, oo.font(6,1).bold?
|
1214
|
+
assert_equal false, oo.font(6,1).italic?
|
1215
|
+
assert_equal true, oo.font(6,1).underline?
|
1216
|
+
|
1217
|
+
# italic underline
|
1218
|
+
assert_equal false, oo.font(7,1).bold?
|
1219
|
+
assert_equal true, oo.font(7,1).italic?
|
1220
|
+
assert_equal true, oo.font(7,1).underline?
|
1221
|
+
|
1222
|
+
# bolded row
|
1223
|
+
assert_equal true, oo.font(8,1).bold?
|
1224
|
+
assert_equal false, oo.font(8,1).italic?
|
1225
|
+
assert_equal false, oo.font(8,1).underline?
|
1226
|
+
|
1227
|
+
# bolded col
|
1228
|
+
assert_equal true, oo.font(9,2).bold?
|
1229
|
+
assert_equal false, oo.font(9,2).italic?
|
1230
|
+
assert_equal false, oo.font(9,2).underline?
|
1231
|
+
|
1232
|
+
# bolded row, italic col
|
1233
|
+
assert_equal true, oo.font(10,3).bold?
|
1234
|
+
assert_equal true, oo.font(10,3).italic?
|
1235
|
+
assert_equal false, oo.font(10,3).underline?
|
1236
|
+
|
1237
|
+
# normal
|
1238
|
+
assert_equal false, oo.font(11,4).bold?
|
1239
|
+
assert_equal false, oo.font(11,4).italic?
|
1240
|
+
assert_equal false, oo.font(11,4).underline?
|
1241
|
+
end
|
1242
|
+
end
|
1243
|
+
|
1244
|
+
# Need to extend to other formats
|
1245
|
+
def test_row_whitespace
|
1246
|
+
# auf dieses Dokument habe ich keinen Zugriff TODO:
|
1247
|
+
with_each_spreadsheet(:name=>'whitespace') do |oo|
|
1248
|
+
oo.default_sheet = "Sheet1"
|
1249
|
+
assert_equal [nil, nil, nil, nil, nil, nil], oo.row(1)
|
1250
|
+
assert_equal [nil, nil, nil, nil, nil, nil], oo.row(2)
|
1251
|
+
assert_equal ["Date", "Start time", "End time", "Pause", "Sum", "Comment"], oo.row(3)
|
1252
|
+
assert_equal [Date.new(2007,5,7), 9.25, 10.25, 0.0, 1.0, "Task 1"], oo.row(4)
|
1253
|
+
assert_equal [nil, nil, nil, nil, nil, nil], oo.row(5)
|
1254
|
+
assert_equal [Date.new(2007,5,7), 10.75, 10.75, 0.0, 0.0, "Task 1"], oo.row(6)
|
1255
|
+
oo.default_sheet = "Sheet2"
|
1256
|
+
assert_equal ["Date", nil, "Start time"], oo.row(1)
|
1257
|
+
assert_equal [Date.new(2007,5,7), nil, 9.25], oo.row(2)
|
1258
|
+
assert_equal [Date.new(2007,5,7), nil, 10.75], oo.row(3)
|
1259
|
+
end
|
1260
|
+
end
|
1261
|
+
|
1262
|
+
def test_col_whitespace
|
1263
|
+
#TODO:
|
1264
|
+
# kein Zugriff auf Dokument whitespace
|
1265
|
+
with_each_spreadsheet(:name=>'whitespace') do |oo|
|
1266
|
+
oo.default_sheet = "Sheet1"
|
1267
|
+
assert_equal ["Date", Date.new(2007,5,7), nil, Date.new(2007,5,7)], oo.column(1)
|
1268
|
+
assert_equal ["Start time", 9.25, nil, 10.75], oo.column(2)
|
1269
|
+
assert_equal ["End time", 10.25, nil, 10.75], oo.column(3)
|
1270
|
+
assert_equal ["Pause", 0.0, nil, 0.0], oo.column(4)
|
1271
|
+
assert_equal ["Sum", 1.0, nil, 0.0], oo.column(5)
|
1272
|
+
assert_equal ["Comment","Task 1", nil, "Task 1"], oo.column(6)
|
1273
|
+
oo.default_sheet = "Sheet2"
|
1274
|
+
assert_equal [nil, nil, nil], oo.column(1)
|
1275
|
+
assert_equal [nil, nil, nil], oo.column(2)
|
1276
|
+
assert_equal ["Date", Date.new(2007,5,7), Date.new(2007,5,7)], oo.column(3)
|
1277
|
+
assert_equal [nil, nil, nil], oo.column(4)
|
1278
|
+
assert_equal [ "Start time", 9.25, 10.75], oo.column(5)
|
1279
|
+
end
|
1280
|
+
end
|
1281
|
+
|
1282
|
+
def test_excelx_links
|
1283
|
+
with_each_spreadsheet(:name=>'link', :format=>:excelx) do |oo|
|
1284
|
+
assert_equal 'Google', oo.cell(1,1)
|
1285
|
+
assert_equal 'http://www.google.com', oo.cell(1,1).href
|
1286
|
+
end
|
1287
|
+
end
|
1288
|
+
|
1289
|
+
# Excel has two base date formats one from 1900 and the other from 1904.
|
1290
|
+
# see #test_base_dates_in_excel
|
1291
|
+
def test_base_dates_in_excelx
|
1292
|
+
with_each_spreadsheet(:name=>'1900_base', :format=>:excelx) do |oo|
|
1293
|
+
assert_equal Date.new(2009,06,15), oo.cell(1,1)
|
1294
|
+
assert_equal :date, oo.celltype(1,1)
|
1295
|
+
end
|
1296
|
+
with_each_spreadsheet(:name=>'1904_base', :format=>:excelx) do |oo|
|
1297
|
+
assert_equal Date.new(2009,06,15), oo.cell(1,1)
|
1298
|
+
assert_equal :date, oo.celltype(1,1)
|
1299
|
+
end
|
1300
|
+
end
|
1301
|
+
|
1302
|
+
def test_cell_methods
|
1303
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
1304
|
+
assert_equal 10, oo.a4 # cell(4,'A')
|
1305
|
+
assert_equal 11, oo.b4 # cell(4,'B')
|
1306
|
+
assert_equal 12, oo.c4 # cell(4,'C')
|
1307
|
+
assert_equal 13, oo.d4 # cell(4,'D')
|
1308
|
+
assert_equal 14, oo.e4 # cell(4,'E')
|
1309
|
+
assert_equal 'ABC', oo.c6('Sheet5')
|
1310
|
+
|
1311
|
+
#assert_raises(ArgumentError) {
|
1312
|
+
assert_raises(NoMethodError) {
|
1313
|
+
# a42a is not a valid cell name, should raise ArgumentError
|
1314
|
+
assert_equal 9999, oo.a42a
|
1315
|
+
}
|
1316
|
+
end
|
1317
|
+
end
|
1318
|
+
|
1319
|
+
|
1320
|
+
# compare large spreadsheets
|
1321
|
+
def test_compare_large_spreadsheets
|
1322
|
+
# problematisch, weil Formeln in Excel nicht unterstützt werden
|
1323
|
+
if LONG_RUN
|
1324
|
+
qq = Roo::OpenOffice.new(File.join('test',"Bibelbund.ods"))
|
1325
|
+
with_each_spreadsheet(:name=>'Bibelbund') do |oo|
|
1326
|
+
# p "comparing Bibelbund.ods with #{oo.class}"
|
1327
|
+
oo.sheets.each do |sh|
|
1328
|
+
oo.first_row.upto(oo.last_row) do |row|
|
1329
|
+
oo.first_column.upto(oo.last_column) do |col|
|
1330
|
+
c1 = qq.cell(row,col,sh)
|
1331
|
+
c1.force_encoding("UTF-8") if c1.class == String
|
1332
|
+
c2 = oo.cell(row,col,sh)
|
1333
|
+
c2.force_encoding("UTF-8") if c2.class == String
|
1334
|
+
assert_equal c1, c2, "diff in #{sh}/#{row}/#{col}}"
|
1335
|
+
assert_equal qq.celltype(row,col,sh), oo.celltype(row,col,sh)
|
1336
|
+
assert_equal qq.formula?(row,col,sh), oo.formula?(row,col,sh) if oo.class != Roo::Excel
|
1337
|
+
end
|
1338
|
+
end
|
1339
|
+
end
|
1340
|
+
end
|
1341
|
+
end # LONG_RUN
|
1342
|
+
end
|
1343
|
+
|
1344
|
+
def test_label
|
1345
|
+
with_each_spreadsheet(:name=>'named_cells', :format=>[:openoffice,:excelx,:libreoffice]) do |oo|
|
1346
|
+
# oo.default_sheet = oo.sheets.first
|
1347
|
+
begin
|
1348
|
+
row,col = oo.label('anton')
|
1349
|
+
rescue ArgumentError
|
1350
|
+
puts "labels error at #{oo.class}"
|
1351
|
+
raise
|
1352
|
+
end
|
1353
|
+
assert_equal 5, row, "error with label in class #{oo.class}"
|
1354
|
+
assert_equal 3, col, "error with label in class #{oo.class}"
|
1355
|
+
|
1356
|
+
row,col = oo.label('anton')
|
1357
|
+
assert_equal 'Anton', oo.cell(row,col), "error with label in class #{oo.class}"
|
1358
|
+
|
1359
|
+
row,col = oo.label('berta')
|
1360
|
+
assert_equal 'Bertha', oo.cell(row,col), "error with label in class #{oo.class}"
|
1361
|
+
|
1362
|
+
row,col = oo.label('caesar')
|
1363
|
+
assert_equal 'Cäsar', oo.cell(row,col),"error with label in class #{oo.class}"
|
1364
|
+
|
1365
|
+
row,col = oo.label('never')
|
1366
|
+
assert_nil row
|
1367
|
+
assert_nil col
|
1368
|
+
|
1369
|
+
row,col,sheet = oo.label('anton')
|
1370
|
+
assert_equal 5, row
|
1371
|
+
assert_equal 3, col
|
1372
|
+
assert_equal "Sheet1", sheet
|
1373
|
+
end
|
1374
|
+
end
|
1375
|
+
|
1376
|
+
def test_method_missing_anton
|
1377
|
+
with_each_spreadsheet(:name=>'named_cells', :format=>[:openoffice,:excelx,:libreoffice]) do |oo|
|
1378
|
+
# oo.default_sheet = oo.sheets.first
|
1379
|
+
assert_equal "Anton", oo.anton
|
1380
|
+
assert_raises(NoMethodError) {
|
1381
|
+
oo.never
|
1382
|
+
}
|
1383
|
+
end
|
1384
|
+
end
|
1385
|
+
|
1386
|
+
def test_labels
|
1387
|
+
with_each_spreadsheet(:name=>'named_cells', :format=>[:openoffice,:excelx,:libreoffice]) do |oo|
|
1388
|
+
# oo.default_sheet = oo.sheets.first
|
1389
|
+
assert_equal [
|
1390
|
+
['anton',[5,3,'Sheet1']],
|
1391
|
+
['berta',[4,2,'Sheet1']],
|
1392
|
+
['caesar',[7,2,'Sheet1']],
|
1393
|
+
], oo.labels, "error with labels array in class #{oo.class}"
|
1394
|
+
end
|
1395
|
+
end
|
1396
|
+
|
1397
|
+
def test_labeled_cells
|
1398
|
+
with_each_spreadsheet(:name=>'named_cells', :format=>[:openoffice,:excelx,:libreoffice]) do |oo|
|
1399
|
+
oo.default_sheet = oo.sheets.first
|
1400
|
+
begin
|
1401
|
+
row,col = oo.label('anton')
|
1402
|
+
rescue ArgumentError
|
1403
|
+
puts "labels error at #{oo.class}"
|
1404
|
+
raise
|
1405
|
+
end
|
1406
|
+
assert_equal 5, row
|
1407
|
+
assert_equal 3, col
|
1408
|
+
|
1409
|
+
row,col = oo.label('anton')
|
1410
|
+
assert_equal 'Anton', oo.cell(row,col)
|
1411
|
+
|
1412
|
+
row,col = oo.label('berta')
|
1413
|
+
assert_equal 'Bertha', oo.cell(row,col)
|
1414
|
+
|
1415
|
+
row,col = oo.label('caesar')
|
1416
|
+
assert_equal 'Cäsar', oo.cell(row,col)
|
1417
|
+
|
1418
|
+
row,col = oo.label('never')
|
1419
|
+
assert_nil row
|
1420
|
+
assert_nil col
|
1421
|
+
|
1422
|
+
row,col,sheet = oo.label('anton')
|
1423
|
+
assert_equal 5, row
|
1424
|
+
assert_equal 3, col
|
1425
|
+
assert_equal "Sheet1", sheet
|
1426
|
+
|
1427
|
+
assert_equal "Anton", oo.anton
|
1428
|
+
assert_raises(NoMethodError) {
|
1429
|
+
row,col = oo.never
|
1430
|
+
}
|
1431
|
+
|
1432
|
+
# Reihenfolge row,col,sheet analog zu #label
|
1433
|
+
assert_equal [
|
1434
|
+
['anton',[5,3,'Sheet1']],
|
1435
|
+
['berta',[4,2,'Sheet1']],
|
1436
|
+
['caesar',[7,2,'Sheet1']],
|
1437
|
+
], oo.labels, "error with labels array in class #{oo.class}"
|
1438
|
+
end
|
1439
|
+
end
|
1440
|
+
|
1441
|
+
require 'matrix'
|
1442
|
+
def test_matrix
|
1443
|
+
with_each_spreadsheet(:name => 'matrix', :format => :openoffice) do |oo|
|
1444
|
+
oo.default_sheet = oo.sheets.first
|
1445
|
+
assert_equal Matrix[
|
1446
|
+
[1.0, 2.0, 3.0],
|
1447
|
+
[4.0, 5.0, 6.0],
|
1448
|
+
[7.0, 8.0, 9.0] ], oo.to_matrix
|
1449
|
+
end
|
1450
|
+
end
|
1451
|
+
|
1452
|
+
def test_matrix_selected_range
|
1453
|
+
with_each_spreadsheet(:name => 'matrix', :format=>:openoffice) do |oo|
|
1454
|
+
oo.default_sheet = 'Sheet2'
|
1455
|
+
assert_equal Matrix[
|
1456
|
+
[1.0, 2.0, 3.0],
|
1457
|
+
[4.0, 5.0, 6.0],
|
1458
|
+
[7.0, 8.0, 9.0] ], oo.to_matrix(3,4,5,6)
|
1459
|
+
end
|
1460
|
+
end
|
1461
|
+
|
1462
|
+
def test_matrix_all_nil
|
1463
|
+
with_each_spreadsheet(:name => 'matrix', :format=>:openoffice) do |oo|
|
1464
|
+
oo.default_sheet = 'Sheet2'
|
1465
|
+
assert_equal Matrix[
|
1466
|
+
[nil, nil, nil],
|
1467
|
+
[nil, nil, nil],
|
1468
|
+
[nil, nil, nil] ], oo.to_matrix(10,10,12,12)
|
1469
|
+
end
|
1470
|
+
end
|
1471
|
+
|
1472
|
+
def test_matrix_values_and_nil
|
1473
|
+
with_each_spreadsheet(:name => 'matrix', :format=>:openoffice) do |oo|
|
1474
|
+
oo.default_sheet = 'Sheet3'
|
1475
|
+
assert_equal Matrix[
|
1476
|
+
[1.0, nil, 3.0],
|
1477
|
+
[4.0, 5.0, 6.0],
|
1478
|
+
[7.0, 8.0, nil] ], oo.to_matrix(1,1,3,3)
|
1479
|
+
end
|
1480
|
+
end
|
1481
|
+
|
1482
|
+
def test_matrix_specifying_sheet
|
1483
|
+
with_each_spreadsheet(:name => 'matrix', :format => :openoffice) do |oo|
|
1484
|
+
oo.default_sheet = oo.sheets.first
|
1485
|
+
assert_equal Matrix[
|
1486
|
+
[1.0, nil, 3.0],
|
1487
|
+
[4.0, 5.0, 6.0],
|
1488
|
+
[7.0, 8.0, nil] ], oo.to_matrix(nil, nil, nil, nil, 'Sheet3')
|
1489
|
+
end
|
1490
|
+
end
|
1491
|
+
|
1492
|
+
# unter Windows soll es laut Bug-Reports nicht moeglich sein, eine Excel-Datei, die
|
1493
|
+
# mit Excel.new geoeffnet wurde nach dem Processing anschliessend zu loeschen.
|
1494
|
+
# Anmerkung: Das Spreadsheet-Gem erlaubt kein explizites Close von Spreadsheet-Dateien,
|
1495
|
+
# was verhindern koennte, das die Datei geloescht werden kann.
|
1496
|
+
# def test_bug_cannot_delete_opened_excel_sheet
|
1497
|
+
# with_each_spreadsheet(:name=>'simple_spreadsheet') do |oo|
|
1498
|
+
# 'kopiere nach temporaere Datei und versuche diese zu oeffnen und zu loeschen'
|
1499
|
+
# end
|
1500
|
+
# end
|
1501
|
+
|
1502
|
+
def test_bug_xlsx_reference_cell
|
1503
|
+
|
1504
|
+
if EXCELX
|
1505
|
+
=begin
|
1506
|
+
If cell A contains a string and cell B references cell A. When reading the value of cell B, the result will be
|
1507
|
+
"0.0" instead of the value of cell A.
|
1508
|
+
|
1509
|
+
With the attached test case, I ran the following code:
|
1510
|
+
spreadsheet = Roo::Excelx.new('formula_string_error.xlsx')
|
1511
|
+
spreadsheet.default_sheet = 'sheet1'
|
1512
|
+
p "A: #{spreadsheet.cell(1, 1)}"
|
1513
|
+
p "B: #{spreadsheet.cell(2, 1)}"
|
1514
|
+
|
1515
|
+
with the following results
|
1516
|
+
"A: TestString"
|
1517
|
+
"B: 0.0"
|
1518
|
+
|
1519
|
+
where the expected result is
|
1520
|
+
"A: TestString"
|
1521
|
+
"B: TestString"
|
1522
|
+
=end
|
1523
|
+
xlsx = Roo::Excelx.new(File.join(TESTDIR, "formula_string_error.xlsx"))
|
1524
|
+
xlsx.default_sheet = xlsx.sheets.first
|
1525
|
+
assert_equal 'Teststring', xlsx.cell('a',1)
|
1526
|
+
assert_equal 'Teststring', xlsx.cell('a',2)
|
1527
|
+
end
|
1528
|
+
end
|
1529
|
+
|
1530
|
+
# #formulas of an empty sheet should return an empty array and not result in
|
1531
|
+
# an error message
|
1532
|
+
# 2011-06-24
|
1533
|
+
def test_bug_formulas_empty_sheet
|
1534
|
+
with_each_spreadsheet(:name =>'emptysheets',
|
1535
|
+
:format=>[:openoffice,:excelx]) do |oo|
|
1536
|
+
oo.default_sheet = oo.sheets.first
|
1537
|
+
oo.formulas
|
1538
|
+
assert_equal([], oo.formulas)
|
1539
|
+
end
|
1540
|
+
end
|
1541
|
+
|
1542
|
+
# #to_yaml of an empty sheet should return an empty string and not result in
|
1543
|
+
# an error message
|
1544
|
+
# 2011-06-24
|
1545
|
+
def test_bug_to_yaml_empty_sheet
|
1546
|
+
with_each_spreadsheet(:name =>'emptysheets',
|
1547
|
+
:format=>[:openoffice,:excelx]) do |oo|
|
1548
|
+
oo.default_sheet = oo.sheets.first
|
1549
|
+
oo.to_yaml
|
1550
|
+
assert_equal('', oo.to_yaml)
|
1551
|
+
end
|
1552
|
+
end
|
1553
|
+
|
1554
|
+
# #to_matrix of an empty sheet should return an empty matrix and not result in
|
1555
|
+
# an error message
|
1556
|
+
# 2011-06-25
|
1557
|
+
def test_bug_to_matrix_empty_sheet
|
1558
|
+
with_each_spreadsheet(:name =>'emptysheets',
|
1559
|
+
:format=>[:openoffice,:excelx]) do |oo|
|
1560
|
+
oo.default_sheet = oo.sheets.first
|
1561
|
+
oo.to_matrix
|
1562
|
+
assert_equal(Matrix.empty(0,0), oo.to_matrix)
|
1563
|
+
end
|
1564
|
+
end
|
1565
|
+
|
1566
|
+
# 2011-08-03
|
1567
|
+
def test_bug_datetime_to_csv
|
1568
|
+
with_each_spreadsheet(:name=>'datetime') do |oo|
|
1569
|
+
Dir.mktmpdir do |tempdir|
|
1570
|
+
datetime_csv_file = File.join(tempdir,"datetime.csv")
|
1571
|
+
|
1572
|
+
assert oo.to_csv(datetime_csv_file)
|
1573
|
+
assert File.exists?(datetime_csv_file)
|
1574
|
+
assert_equal "", file_diff('test/files/so_datetime.csv', datetime_csv_file)
|
1575
|
+
end
|
1576
|
+
end
|
1577
|
+
end
|
1578
|
+
|
1579
|
+
# 2011-08-11
|
1580
|
+
def test_bug_openoffice_formula_missing_letters
|
1581
|
+
if LIBREOFFICE
|
1582
|
+
# Dieses Dokument wurde mit LibreOffice angelegt.
|
1583
|
+
# Keine Ahnung, ob es damit zusammenhaengt, das diese
|
1584
|
+
# Formeln anders sind, als in der Datei formula.ods, welche
|
1585
|
+
# mit OpenOffice angelegt wurde.
|
1586
|
+
# Bei den OpenOffice-Dateien ist in diesem Feld in der XML-
|
1587
|
+
# Datei of: als Prefix enthalten, waehrend in dieser Datei
|
1588
|
+
# irgendetwas mit oooc: als Prefix verwendet wird.
|
1589
|
+
oo = Roo::OpenOffice.new(File.join(TESTDIR,'dreimalvier.ods'))
|
1590
|
+
oo.default_sheet = oo.sheets.first
|
1591
|
+
assert_equal '=SUM([.A1:.D1])', oo.formula('e',1)
|
1592
|
+
assert_equal '=SUM([.A2:.D2])', oo.formula('e',2)
|
1593
|
+
assert_equal '=SUM([.A3:.D3])', oo.formula('e',3)
|
1594
|
+
assert_equal [
|
1595
|
+
[1,5,'=SUM([.A1:.D1])'],
|
1596
|
+
[2,5,'=SUM([.A2:.D2])'],
|
1597
|
+
[3,5,'=SUM([.A3:.D3])'],
|
1598
|
+
], oo.formulas
|
1599
|
+
|
1600
|
+
end
|
1601
|
+
end
|
1602
|
+
|
1603
|
+
=begin
|
1604
|
+
def test_postprocessing_and_types_in_csv
|
1605
|
+
if CSV
|
1606
|
+
oo = CSV.new(File.join(TESTDIR,'csvtypes.csv'))
|
1607
|
+
oo.default_sheet = oo.sheets.first
|
1608
|
+
assert_equal(1,oo.a1)
|
1609
|
+
assert_equal(:float,oo.celltype('A',1))
|
1610
|
+
assert_equal("2",oo.b1)
|
1611
|
+
assert_equal(:string,oo.celltype('B',1))
|
1612
|
+
assert_equal("Mayer",oo.c1)
|
1613
|
+
assert_equal(:string,oo.celltype('C',1))
|
1614
|
+
end
|
1615
|
+
end
|
1616
|
+
=end
|
1617
|
+
|
1618
|
+
=begin
|
1619
|
+
def test_postprocessing_with_callback_function
|
1620
|
+
if CSV
|
1621
|
+
oo = CSV.new(File.join(TESTDIR,'csvtypes.csv'))
|
1622
|
+
oo.default_sheet = oo.sheets.first
|
1623
|
+
|
1624
|
+
#
|
1625
|
+
assert_equal(1, oo.last_column)
|
1626
|
+
end
|
1627
|
+
end
|
1628
|
+
=end
|
1629
|
+
|
1630
|
+
=begin
|
1631
|
+
def x_123
|
1632
|
+
class ::CSV
|
1633
|
+
def cell_postprocessing(row,col,value)
|
1634
|
+
if row < 3
|
1635
|
+
return nil
|
1636
|
+
end
|
1637
|
+
return value
|
1638
|
+
end
|
1639
|
+
end
|
1640
|
+
end
|
1641
|
+
=end
|
1642
|
+
|
1643
|
+
def test_nil_rows_and_lines_csv
|
1644
|
+
# x_123
|
1645
|
+
if CSV
|
1646
|
+
oo = Roo::CSV.new(File.join(TESTDIR,'Bibelbund.csv'))
|
1647
|
+
oo.default_sheet = oo.sheets.first
|
1648
|
+
assert_equal 1, oo.first_row
|
1649
|
+
end
|
1650
|
+
end
|
1651
|
+
|
1652
|
+
def test_bug_pfand_from_windows_phone_xlsx
|
1653
|
+
return if defined? JRUBY_VERSION
|
1654
|
+
with_each_spreadsheet(:name=>'Pfand_from_windows_phone', :format=>:excelx) do |oo|
|
1655
|
+
oo.default_sheet = oo.sheets.first
|
1656
|
+
assert_equal ['Blatt1','Blatt2','Blatt3'], oo.sheets
|
1657
|
+
assert_equal 'Summe', oo.cell('b',1)
|
1658
|
+
|
1659
|
+
assert_equal Date.new(2011,9,14), oo.cell('a',2)
|
1660
|
+
assert_equal :date, oo.celltype('a',2)
|
1661
|
+
assert_equal Date.new(2011,9,15), oo.cell('a',3)
|
1662
|
+
assert_equal :date, oo.celltype('a',3)
|
1663
|
+
|
1664
|
+
assert_equal 3.81, oo.cell('b',2)
|
1665
|
+
assert_equal "SUM(C2:L2)", oo.formula('b',2)
|
1666
|
+
assert_equal 0.7, oo.cell('c',2)
|
1667
|
+
end # each
|
1668
|
+
end
|
1669
|
+
|
1670
|
+
def test_comment
|
1671
|
+
with_each_spreadsheet(:name=>'comments', :format=>[:openoffice,:libreoffice,
|
1672
|
+
:excelx]) do |oo|
|
1673
|
+
oo.default_sheet = oo.sheets.first
|
1674
|
+
assert_equal 'Kommentar fuer B4',oo.comment('b',4)
|
1675
|
+
assert_equal 'Kommentar fuer B5',oo.comment('b',5)
|
1676
|
+
assert_nil oo.comment('b',99)
|
1677
|
+
# no comment at the second page
|
1678
|
+
oo.default_sheet = oo.sheets[1]
|
1679
|
+
assert_nil oo.comment('b',4)
|
1680
|
+
end
|
1681
|
+
end
|
1682
|
+
|
1683
|
+
def test_comments
|
1684
|
+
with_each_spreadsheet(:name=>'comments', :format=>[:openoffice,:libreoffice,
|
1685
|
+
:excelx]) do |oo|
|
1686
|
+
oo.default_sheet = oo.sheets.first
|
1687
|
+
assert_equal [
|
1688
|
+
[4, 2, "Kommentar fuer B4"],
|
1689
|
+
[5, 2, "Kommentar fuer B5"],
|
1690
|
+
], oo.comments(oo.sheets.first), "comments error in class #{oo.class}"
|
1691
|
+
# no comments at the second page
|
1692
|
+
oo.default_sheet = oo.sheets[1]
|
1693
|
+
assert_equal [], oo.comments, "comments error in class #{oo.class}"
|
1694
|
+
end
|
1695
|
+
|
1696
|
+
with_each_spreadsheet(:name=>'comments-google', :format=>[:excelx]) do |oo|
|
1697
|
+
oo.default_sheet = oo.sheets.first
|
1698
|
+
assert_equal [[1, 1, "this is a comment\n\t-Steven Daniels"]], oo.comments(oo.sheets.first), "comments error in class #{oo.class}"
|
1699
|
+
end
|
1700
|
+
end
|
1701
|
+
|
1702
|
+
## PREVIOUSLY SKIPPED
|
1703
|
+
|
1704
|
+
# don't have these test files so removing. We can easily add in
|
1705
|
+
# by modifying with_each_spreadsheet
|
1706
|
+
GNUMERIC_ODS = false # do gnumeric with ods files Tests?
|
1707
|
+
OPENOFFICEWRITE = false # experimental: write access with OO-Documents
|
1708
|
+
|
1709
|
+
def test_writeopenoffice
|
1710
|
+
if OPENOFFICEWRITE
|
1711
|
+
File.cp(File.join(TESTDIR,"numbers1.ods"),
|
1712
|
+
File.join(TESTDIR,"numbers2.ods"))
|
1713
|
+
File.cp(File.join(TESTDIR,"numbers2.ods"),
|
1714
|
+
File.join(TESTDIR,"bak_numbers2.ods"))
|
1715
|
+
oo = OpenOffice.new(File.join(TESTDIR,"numbers2.ods"))
|
1716
|
+
oo.default_sheet = oo.sheets.first
|
1717
|
+
oo.first_row.upto(oo.last_row) {|y|
|
1718
|
+
oo.first_column.upto(oo.last_column) {|x|
|
1719
|
+
unless oo.empty?(y,x)
|
1720
|
+
# oo.set(y, x, oo.cell(y,x) + 7) if oo.celltype(y,x) == "float"
|
1721
|
+
oo.set(y, x, oo.cell(y,x) + 7) if oo.celltype(y,x) == :float
|
1722
|
+
end
|
1723
|
+
}
|
1724
|
+
}
|
1725
|
+
oo.save
|
1726
|
+
|
1727
|
+
oo1 = Roo::OpenOffice.new(File.join(TESTDIR,"numbers2.ods"))
|
1728
|
+
oo2 = Roo::OpenOffice.new(File.join(TESTDIR,"bak_numbers2.ods"))
|
1729
|
+
#p oo2.to_s
|
1730
|
+
assert_equal 999, oo2.cell('a',1), oo2.cell('a',1)
|
1731
|
+
assert_equal oo2.cell('a',1) + 7, oo1.cell('a',1)
|
1732
|
+
assert_equal oo2.cell('b',1)+7, oo1.cell('b',1)
|
1733
|
+
assert_equal oo2.cell('c',1)+7, oo1.cell('c',1)
|
1734
|
+
assert_equal oo2.cell('d',1)+7, oo1.cell('d',1)
|
1735
|
+
assert_equal oo2.cell('a',2)+7, oo1.cell('a',2)
|
1736
|
+
assert_equal oo2.cell('b',2)+7, oo1.cell('b',2)
|
1737
|
+
assert_equal oo2.cell('c',2)+7, oo1.cell('c',2)
|
1738
|
+
assert_equal oo2.cell('d',2)+7, oo1.cell('d',2)
|
1739
|
+
assert_equal oo2.cell('e',2)+7, oo1.cell('e',2)
|
1740
|
+
|
1741
|
+
File.cp(File.join(TESTDIR,"bak_numbers2.ods"),
|
1742
|
+
File.join(TESTDIR,"numbers2.ods"))
|
1743
|
+
end
|
1744
|
+
end
|
1745
|
+
|
1746
|
+
def common_possible_bug_snowboard_cells(ss)
|
1747
|
+
assert_equal "A.", ss.cell(13,'A'), ss.class
|
1748
|
+
assert_equal 147, ss.cell(13,'f'), ss.class
|
1749
|
+
assert_equal 152, ss.cell(13,'g'), ss.class
|
1750
|
+
assert_equal 156, ss.cell(13,'h'), ss.class
|
1751
|
+
assert_equal 158, ss.cell(13,'i'), ss.class
|
1752
|
+
assert_equal 160, ss.cell(13,'j'), ss.class
|
1753
|
+
assert_equal 164, ss.cell(13,'k'), ss.class
|
1754
|
+
assert_equal 168, ss.cell(13,'l'), ss.class
|
1755
|
+
assert_equal :string, ss.celltype(13,'m'), ss.class
|
1756
|
+
assert_equal "159W", ss.cell(13,'m'), ss.class
|
1757
|
+
assert_equal "164W", ss.cell(13,'n'), ss.class
|
1758
|
+
assert_equal "168W", ss.cell(13,'o'), ss.class
|
1759
|
+
end
|
1760
|
+
|
1761
|
+
# def test_false_encoding
|
1762
|
+
# ex = Roo::Excel.new(File.join(TESTDIR,'false_encoding.xls'))
|
1763
|
+
# ex.default_sheet = ex.sheets.first
|
1764
|
+
# assert_equal "Sheet1", ex.sheets.first
|
1765
|
+
# ex.first_row.upto(ex.last_row) do |row|
|
1766
|
+
# ex.first_column.upto(ex.last_column) do |col|
|
1767
|
+
# content = ex.cell(row,col)
|
1768
|
+
# puts "#{row}/#{col}"
|
1769
|
+
# #puts content if ! ex.empty?(row,col) or ex.formula?(row,col)
|
1770
|
+
# if ex.formula?(row,col)
|
1771
|
+
# #! ex.empty?(row,col)
|
1772
|
+
# puts content
|
1773
|
+
# end
|
1774
|
+
# end
|
1775
|
+
# end
|
1776
|
+
# end
|
1777
|
+
|
1778
|
+
def test_download_uri
|
1779
|
+
if ONLINE
|
1780
|
+
if OPENOFFICE
|
1781
|
+
assert_raises(RuntimeError) {
|
1782
|
+
Roo::OpenOffice.new("http://gibbsnichtdomainxxxxx.com/file.ods")
|
1783
|
+
}
|
1784
|
+
end
|
1785
|
+
if EXCELX
|
1786
|
+
assert_raises(RuntimeError) {
|
1787
|
+
Roo::Excelx.new("http://gibbsnichtdomainxxxxx.com/file.xlsx")
|
1788
|
+
}
|
1789
|
+
end
|
1790
|
+
end
|
1791
|
+
end
|
1792
|
+
|
1793
|
+
def test_download_uri_with_query_string
|
1794
|
+
dir = File.expand_path("#{File.dirname __FILE__}/files")
|
1795
|
+
{ xlsx: [EXCELX, Roo::Excelx],
|
1796
|
+
ods: [OPENOFFICE, Roo::OpenOffice]}.each do |extension, (flag, type)|
|
1797
|
+
if flag
|
1798
|
+
file = "#{dir}/simple_spreadsheet.#{extension}"
|
1799
|
+
url = "http://test.example.com/simple_spreadsheet.#{extension}?query-param=value"
|
1800
|
+
stub_request(:any, url).to_return(body: File.read(file))
|
1801
|
+
spreadsheet = type.new(url)
|
1802
|
+
spreadsheet.default_sheet = spreadsheet.sheets.first
|
1803
|
+
assert_equal 'Task 1', spreadsheet.cell('f', 4)
|
1804
|
+
end
|
1805
|
+
end
|
1806
|
+
end
|
1807
|
+
|
1808
|
+
# def test_soap_server
|
1809
|
+
# #threads = []
|
1810
|
+
# #threads << Thread.new("serverthread") do
|
1811
|
+
# fork do
|
1812
|
+
# p "serverthread started"
|
1813
|
+
# puts "in child, pid = #$$"
|
1814
|
+
# puts `/usr/bin/ruby rooserver.rb`
|
1815
|
+
# p "serverthread finished"
|
1816
|
+
# end
|
1817
|
+
# #threads << Thread.new("clientthread") do
|
1818
|
+
# p "clientthread started"
|
1819
|
+
# sleep 10
|
1820
|
+
# proxy = SOAP::RPC::Driver.new("http://localhost:12321","spreadsheetserver")
|
1821
|
+
# proxy.add_method('cell','row','col')
|
1822
|
+
# proxy.add_method('officeversion')
|
1823
|
+
# proxy.add_method('last_row')
|
1824
|
+
# proxy.add_method('last_column')
|
1825
|
+
# proxy.add_method('first_row')
|
1826
|
+
# proxy.add_method('first_column')
|
1827
|
+
# proxy.add_method('sheets')
|
1828
|
+
# proxy.add_method('set_default_sheet','s')
|
1829
|
+
# proxy.add_method('ferien_fuer_region', 'region')
|
1830
|
+
|
1831
|
+
# sheets = proxy.sheets
|
1832
|
+
# p sheets
|
1833
|
+
# proxy.set_default_sheet(sheets.first)
|
1834
|
+
|
1835
|
+
# assert_equal 1, proxy.first_row
|
1836
|
+
# assert_equal 1, proxy.first_column
|
1837
|
+
# assert_equal 187, proxy.last_row
|
1838
|
+
# assert_equal 7, proxy.last_column
|
1839
|
+
# assert_equal 42, proxy.cell('C',8)
|
1840
|
+
# assert_equal 43, proxy.cell('F',12)
|
1841
|
+
# assert_equal "1.0", proxy.officeversion
|
1842
|
+
# p "clientthread finished"
|
1843
|
+
# #end
|
1844
|
+
# #threads.each {|t| t.join }
|
1845
|
+
# puts "fertig"
|
1846
|
+
# Process.kill("INT",pid)
|
1847
|
+
# pid = Process.wait
|
1848
|
+
# puts "child terminated, pid= #{pid}, status= #{$?.exitstatus}"
|
1849
|
+
# end
|
1850
|
+
|
1851
|
+
def split_coord(s)
|
1852
|
+
letter = ""
|
1853
|
+
number = 0
|
1854
|
+
i = 0
|
1855
|
+
while i<s.length and "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".include?(s[i,1])
|
1856
|
+
letter += s[i,1]
|
1857
|
+
i+=1
|
1858
|
+
end
|
1859
|
+
while i<s.length and "01234567890".include?(s[i,1])
|
1860
|
+
number = number*10 + s[i,1].to_i
|
1861
|
+
i+=1
|
1862
|
+
end
|
1863
|
+
if letter=="" or number==0
|
1864
|
+
raise ArgumentError
|
1865
|
+
end
|
1866
|
+
return letter,number
|
1867
|
+
end
|
1868
|
+
|
1869
|
+
#def sum(s,expression)
|
1870
|
+
# arg = expression.split(':')
|
1871
|
+
# b,z = split_coord(arg[0])
|
1872
|
+
# first_row = z
|
1873
|
+
# first_col = OpenOffice.letter_to_number(b)
|
1874
|
+
# b,z = split_coord(arg[1])
|
1875
|
+
# last_row = z
|
1876
|
+
# last_col = OpenOffice.letter_to_number(b)
|
1877
|
+
# result = 0
|
1878
|
+
# first_row.upto(last_row) {|row|
|
1879
|
+
# first_col.upto(last_col) {|col|
|
1880
|
+
# result = result + s.cell(row,col)
|
1881
|
+
# }
|
1882
|
+
# }
|
1883
|
+
# result
|
1884
|
+
#end
|
1885
|
+
|
1886
|
+
#def test_dsl
|
1887
|
+
# s = OpenOffice.new(File.join(TESTDIR,"numbers1.ods"))
|
1888
|
+
# s.default_sheet = s.sheets.first
|
1889
|
+
#
|
1890
|
+
# s.set 'a',1, 5
|
1891
|
+
# s.set 'b',1, 3
|
1892
|
+
# s.set 'c',1, 7
|
1893
|
+
# s.set('a',2, s.cell('a',1)+s.cell('b',1))
|
1894
|
+
# assert_equal 8, s.cell('a',2)
|
1895
|
+
#
|
1896
|
+
# assert_equal 15, sum(s,'A1:C1')
|
1897
|
+
# end
|
1898
|
+
|
1899
|
+
#def test_create_spreadsheet1
|
1900
|
+
# name = File.join(TESTDIR,'createdspreadsheet.ods')
|
1901
|
+
# rm(name) if File.exists?(File.join(TESTDIR,'createdspreadsheet.ods'))
|
1902
|
+
# # anlegen, falls noch nicht existierend
|
1903
|
+
# s = OpenOffice.new(name,true)
|
1904
|
+
# assert File.exists?(name)
|
1905
|
+
#end
|
1906
|
+
|
1907
|
+
#def test_create_spreadsheet2
|
1908
|
+
# # anlegen, falls noch nicht existierend
|
1909
|
+
# s = OpenOffice.new(File.join(TESTDIR,"createdspreadsheet.ods"),true)
|
1910
|
+
# s.set 'a',1,42
|
1911
|
+
# s.set 'b',1,43
|
1912
|
+
# s.set 'c',1,44
|
1913
|
+
# s.save
|
1914
|
+
#
|
1915
|
+
# t = OpenOffice.new(File.join(TESTDIR,"createdspreadsheet.ods"))
|
1916
|
+
# assert_equal 42, t.cell(1,'a')
|
1917
|
+
# assert_equal 43, t.cell('b',1)
|
1918
|
+
# assert_equal 44, t.cell('c',3)
|
1919
|
+
#end
|
1920
|
+
|
1921
|
+
# We don't have the bode-v1.xlsx test file
|
1922
|
+
# #TODO: xlsx-Datei anpassen!
|
1923
|
+
# def test_excelx_download_uri_and_zipped
|
1924
|
+
# #TODO: gezippte xlsx Datei online zum Testen suchen
|
1925
|
+
# if EXCELX
|
1926
|
+
# if ONLINE
|
1927
|
+
# url = 'http://stiny-leonhard.de/bode-v1.xlsx.zip'
|
1928
|
+
# excel = Roo::Excelx.new(url, :zip)
|
1929
|
+
# assert_equal 'ist "e" im Nenner von H(s)', excel.cell('b', 5)
|
1930
|
+
# end
|
1931
|
+
# end
|
1932
|
+
# end
|
1933
|
+
|
1934
|
+
# def test_excelx_zipped
|
1935
|
+
# # TODO: bode...xls bei Gelegenheit nach .xlsx konverieren lassen und zippen!
|
1936
|
+
# if EXCELX
|
1937
|
+
# # diese Datei gibt es noch nicht gezippt
|
1938
|
+
# excel = Roo::Excelx.new(File.join(TESTDIR,"bode-v1.xlsx.zip"), :zip)
|
1939
|
+
# assert excel
|
1940
|
+
# assert_raises(ArgumentError) {
|
1941
|
+
# assert_equal 'ist "e" im Nenner von H(s)', excel.cell('b', 5)
|
1942
|
+
# }
|
1943
|
+
# excel.default_sheet = excel.sheets.first
|
1944
|
+
# assert_equal 'ist "e" im Nenner von H(s)', excel.cell('b', 5)
|
1945
|
+
# end
|
1946
|
+
# end
|
1947
|
+
|
1948
|
+
def test_csv_parsing_with_headers
|
1949
|
+
return unless CSV
|
1950
|
+
headers = ["TITEL", "VERFASSER", "OBJEKT", "NUMMER", "SEITE", "INTERNET", "PC", "KENNUNG"]
|
1951
|
+
|
1952
|
+
oo = Roo::Spreadsheet.open(File.join(TESTDIR, 'Bibelbund.csv'))
|
1953
|
+
parsed = oo.parse(:headers => true)
|
1954
|
+
assert_equal headers, parsed[1].keys
|
1955
|
+
end
|
1956
|
+
|
1957
|
+
def test_bug_numbered_sheet_names
|
1958
|
+
with_each_spreadsheet(:name=>'bug-numbered-sheet-names', :format=>:excelx) do |oo|
|
1959
|
+
oo.each_with_pagename { }
|
1960
|
+
end
|
1961
|
+
end
|
1962
|
+
|
1963
|
+
def test_parsing_xslx_from_numbers
|
1964
|
+
return unless EXCELX
|
1965
|
+
xlsx = Roo::Excelx.new(File.join(TESTDIR, "numbers-export.xlsx"))
|
1966
|
+
|
1967
|
+
xlsx.default_sheet = xlsx.sheets.first
|
1968
|
+
assert_equal 'Sheet 1', xlsx.cell('a',1)
|
1969
|
+
|
1970
|
+
# Another buggy behavior of Numbers 3.1: if a warkbook has more than a
|
1971
|
+
# single sheet, all sheets except the first one will have an extra row and
|
1972
|
+
# column added to the beginning. That's why we assert against cell B2 and
|
1973
|
+
# not A1
|
1974
|
+
xlsx.default_sheet = xlsx.sheets.last
|
1975
|
+
assert_equal 'Sheet 2', xlsx.cell('b',2)
|
1976
|
+
end
|
1977
|
+
|
1978
|
+
def test_openoffice_encryption
|
1979
|
+
if OPENOFFICE
|
1980
|
+
assert_raises(ArgumentError) { Roo::LibreOffice.new(File.join(TESTDIR, "encrypted-letmein.ods")) }
|
1981
|
+
assert_raises(ArgumentError) { Roo::LibreOffice.new(File.join(TESTDIR, "encrypted-letmein.ods"), :password => "badpassword") }
|
1982
|
+
oo = Roo::LibreOffice.new(File.join(TESTDIR, "encrypted-letmein.ods"), :password => "letmein")
|
1983
|
+
oo.default_sheet = oo.sheets.first
|
1984
|
+
assert_equal "Hello World", oo.cell('a',1)
|
1985
|
+
end
|
1986
|
+
end
|
1987
|
+
|
1988
|
+
def test_expand_merged_range
|
1989
|
+
return unless EXCELX
|
1990
|
+
xlsx = Roo::Excelx.new(File.join(TESTDIR, "merged_ranges.xlsx"), {:expand_merged_ranges => true})
|
1991
|
+
for row in 3..7 do
|
1992
|
+
for col in 'a'..'b'
|
1993
|
+
if row > 3 && row < 7 && col == 'a'
|
1994
|
+
assert_equal 'vertical1', xlsx.cell(col,row)
|
1995
|
+
else
|
1996
|
+
assert_nil xlsx.cell(col,row)
|
1997
|
+
end
|
1998
|
+
end
|
1999
|
+
end
|
2000
|
+
for row in 3..11 do
|
2001
|
+
for col in 'f'..'h'
|
2002
|
+
if row > 3 && row < 11 && col == 'g'
|
2003
|
+
assert_equal 'vertical2', xlsx.cell(col,row)
|
2004
|
+
else
|
2005
|
+
assert_nil xlsx.cell(col,row)
|
2006
|
+
end
|
2007
|
+
end
|
2008
|
+
end
|
2009
|
+
for row in 3..5 do
|
2010
|
+
for col in 'b'..'f'
|
2011
|
+
if row == 4 && col > 'b' && col < 'f'
|
2012
|
+
assert_equal 'horizontal', xlsx.cell(col,row)
|
2013
|
+
else
|
2014
|
+
assert_nil xlsx.cell(col,row)
|
2015
|
+
end
|
2016
|
+
end
|
2017
|
+
end
|
2018
|
+
for row in 8..13 do
|
2019
|
+
for col in 'a'..'e'
|
2020
|
+
if row > 8 && row < 13 && col > 'a' && col < 'e'
|
2021
|
+
assert_equal 'block', xlsx.cell(col,row)
|
2022
|
+
else
|
2023
|
+
assert_nil xlsx.cell(col,row)
|
2024
|
+
end
|
2025
|
+
end
|
2026
|
+
end
|
2027
|
+
end
|
2028
|
+
|
2029
|
+
def test_noexpand_merged_range
|
2030
|
+
return unless EXCELX
|
2031
|
+
xlsx = Roo::Excelx.new(File.join(TESTDIR, "merged_ranges.xlsx"))
|
2032
|
+
for row in 3..7 do
|
2033
|
+
for col in 'a'..'b'
|
2034
|
+
if row == 4 && col == 'a'
|
2035
|
+
assert_equal 'vertical1', xlsx.cell(col,row)
|
2036
|
+
else
|
2037
|
+
assert_nil xlsx.cell(col,row)
|
2038
|
+
end
|
2039
|
+
end
|
2040
|
+
end
|
2041
|
+
for row in 3..11 do
|
2042
|
+
for col in 'f'..'h'
|
2043
|
+
if row == 4 && col == 'g'
|
2044
|
+
assert_equal 'vertical2', xlsx.cell(col,row)
|
2045
|
+
else
|
2046
|
+
assert_nil xlsx.cell(col,row)
|
2047
|
+
end
|
2048
|
+
end
|
2049
|
+
end
|
2050
|
+
for row in 3..5 do
|
2051
|
+
for col in 'b'..'f'
|
2052
|
+
if row == 4 && col == 'c'
|
2053
|
+
assert_equal 'horizontal', xlsx.cell(col,row)
|
2054
|
+
else
|
2055
|
+
assert_nil xlsx.cell(col,row)
|
2056
|
+
end
|
2057
|
+
end
|
2058
|
+
end
|
2059
|
+
for row in 8..13 do
|
2060
|
+
for col in 'a'..'e'
|
2061
|
+
if row == 9 && col == 'b'
|
2062
|
+
assert_equal 'block', xlsx.cell(col,row)
|
2063
|
+
else
|
2064
|
+
assert_nil xlsx.cell(col,row)
|
2065
|
+
end
|
2066
|
+
end
|
2067
|
+
end
|
2068
|
+
end
|
2069
|
+
|
2070
|
+
def test_open_stream
|
2071
|
+
return unless EXCELX
|
2072
|
+
file_contents = File.read File.join(TESTDIR, fixture_filename(:numbers1, :excelx)), encoding: 'BINARY'
|
2073
|
+
stream = StringIO.new(file_contents)
|
2074
|
+
xlsx = Roo::Excelx.new(stream)
|
2075
|
+
assert_equal ["Tabelle1","Name of Sheet 2","Sheet3","Sheet4","Sheet5"], xlsx.sheets
|
2076
|
+
end
|
2077
|
+
|
2078
|
+
def test_close
|
2079
|
+
with_each_spreadsheet(:name=>'numbers1') do |oo|
|
2080
|
+
next unless (tempdir = oo.instance_variable_get('@tmpdir'))
|
2081
|
+
oo.close
|
2082
|
+
assert !File.exists?(tempdir), "Expected #{tempdir} to be cleaned up, but it still exists"
|
2083
|
+
end
|
2084
|
+
end
|
2085
|
+
|
2086
|
+
def test_cleanup_on_error
|
2087
|
+
old_temp_files = Dir.open(Dir.tmpdir).to_a
|
2088
|
+
with_each_spreadsheet(:name=>'non_existent_file', :ignore_errors=>true) do |oo|; end
|
2089
|
+
assert_equal Dir.open(Dir.tmpdir).to_a, old_temp_files
|
2090
|
+
end
|
2091
|
+
end # class
|