roo 1.2.3 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,5 @@
1
1
  def spreadsheet(spreadsheet, sheets, options={})
2
+ @rspreadsheet = spreadsheet
2
3
  coordinates = true # default
3
4
  o=""
4
5
  if options[:coordinates] != nil
@@ -1,8 +1,8 @@
1
1
  module Roo #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
- MINOR = 2
5
- TINY = 3
4
+ MINOR = 3
5
+ TINY = 5
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
File without changes
Binary file
Binary file
Binary file
File without changes
Binary file
@@ -1 +1 @@
1
- this is intionally not a spreadsheet file
1
+ this is intentionally not a spreadsheet file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -8,7 +8,9 @@
8
8
  # (like 'diff') must be changed (or commented out ;-)) if you want to run
9
9
  # the tests under another OS
10
10
  #
11
- require File.dirname(__FILE__) + '/test_helper.rb'
11
+
12
+ TESTDIR = File.dirname(__FILE__)
13
+ require TESTDIR + '/test_helper.rb'
12
14
  #require 'soap/rpc/driver'
13
15
  require 'fileutils'
14
16
  require 'timeout'
@@ -42,17 +44,27 @@ end
42
44
  class Test::Unit::TestCase
43
45
  def key_of(spreadsheetname)
44
46
  begin
47
+
45
48
  return {
46
- 'numbers1' => "o10837434939102457526.4784396906364855777",
47
- 'borders' => "o10837434939102457526.664868920231926255",
48
- 'simple_spreadsheet' => "ptu6bbahNZpYe-L1vEBmgGA",
49
+ 'formula' => 'rt4Pw1WmjxFtyfrqqy94wPw',
50
+ "write.me" => 'r6m7HFlUOwst0RTUTuhQ0Ow',
51
+ 'numbers1' => "rYraCzjxTtkxw1NxHJgDU8Q",
52
+ 'borders' => "r_nLYMft6uWg_PT9Rc2urXw",
53
+ 'simple_spreadsheet' => "r3aMMCBCA153TmU_wyIaxfw",
49
54
  'testnichtvorhandenBibelbund.ods' => "invalidkeyforanyspreadsheet", # !!! intentionally false key
50
- "only_one_sheet" => "o10837434939102457526.762705759906130135",
51
- "write.me" => 'ptu6bbahNZpY0N0RrxQbWdw&hl',
52
- 'formula' => 'o10837434939102457526.3022866619437760118',
53
- 'time-test' => 'ptu6bbahNZpYBMhk01UfXSg',
54
- 'datetime' => "ptu6bbahNZpYQEtZwzL_dZQ",
55
+ "only_one_sheet" => "rqRtkcPJ97nhQ0m9ksDw2rA",
56
+ 'time-test' => 'r2XfDBJMrLPjmuLrPQQrEYw',
57
+ 'datetime' => "r2kQpXWr6xOSUpw9MyXavYg",
55
58
  }[spreadsheetname]
59
+ # 'numbers1' => "o10837434939102457526.4784396906364855777",
60
+ # 'borders' => "o10837434939102457526.664868920231926255",
61
+ # 'simple_spreadsheet' => "ptu6bbahNZpYe-L1vEBmgGA",
62
+ # 'testnichtvorhandenBibelbund.ods' => "invalidkeyforanyspreadsheet", # !!! intentionally false key
63
+ # "only_one_sheet" => "o10837434939102457526.762705759906130135",
64
+ # "write.me" => 'ptu6bbahNZpY0N0RrxQbWdw&hl',
65
+ # 'formula' => 'o10837434939102457526.3022866619437760118',
66
+ # 'time-test' => 'ptu6bbahNZpYBMhk01UfXSg',
67
+ # 'datetime' => "ptu6bbahNZpYQEtZwzL_dZQ",
56
68
  rescue
57
69
  raise "unknown spreadsheetname: #{spreadsheetname}"
58
70
  end
@@ -106,11 +118,11 @@ end
106
118
 
107
119
  class TestRoo < Test::Unit::TestCase
108
120
 
109
- OPENOFFICE = true # do Openoffice-Spreadsheet Tests?
110
- EXCEL = true # do Excel Tests?
111
- GOOGLE = true # do Google-Spreadsheet Tests?
112
- GNUMERIC_ODS = false # do gnumeric with ods files Tests?
113
- EXCELX = true # do Excel-X Tests? (.xlsx-files)
121
+ OPENOFFICE = true # do Openoffice-Spreadsheet Tests?
122
+ EXCEL = true # do Excel Tests?
123
+ GOOGLE = false # do Google-Spreadsheet Tests?
124
+ GNUMERIC_ODS = false # do gnumeric with ods files Tests?
125
+ EXCELX = true # do Excel-X Tests? (.xlsx-files)
114
126
 
115
127
  OPENOFFICEWRITE = false # experimental: write access with OO-Documents
116
128
  ONLINE = true
@@ -127,27 +139,30 @@ class TestRoo < Test::Unit::TestCase
127
139
  assert_equal 42*60, 42.minutes
128
140
  end
129
141
 
142
+ # Using Date.strptime so check that it's using the method
143
+ # with the value set in date_format
130
144
  def test_date
131
- assert Google.date?("21/11/1962")
132
- assert_equal Date.new(1962,11,21), Google.to_date("21/11/1962")
133
-
134
- assert !Google.date?("21")
135
- assert_nil Google.to_date("21")
136
-
137
- assert !Google.date?("21/11")
138
- assert_nil Google.to_date("21/11")
139
-
140
- assert !Google.date?("Mittwoch/21/1961")
141
- assert_nil Google.to_date("Mittwoch/21/1961")
145
+ if GOOGLE
146
+ oo = Google.new(key_of("numbers1"))
147
+ # should default to DDMMYYYY
148
+ assert oo.date?("21/11/1962") == true
149
+ assert oo.date?("11/21/1962") == false
150
+ oo.date_format = '%m/%d/%Y'
151
+ assert oo.date?("21/11/1962") == false
152
+ assert oo.date?("11/21/1962") == true
153
+ oo.date_format = '%Y-%m-%d'
154
+ assert oo.date?("1962-11-21") == true
155
+ assert oo.date?("1962-21-11") == false
156
+ end
142
157
  end
143
158
 
144
159
  def test_classes
145
160
  if OPENOFFICE
146
- oo = Openoffice.new(File.join("test","numbers1.ods"))
161
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
147
162
  assert_kind_of Openoffice, oo
148
163
  end
149
164
  if EXCEL
150
- oo = Excel.new(File.join("test","numbers1.xls"))
165
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
151
166
  assert_kind_of Excel, oo
152
167
  end
153
168
  if GOOGLE
@@ -155,7 +170,7 @@ class TestRoo < Test::Unit::TestCase
155
170
  assert_kind_of Google, oo
156
171
  end
157
172
  if EXCELX
158
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
173
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
159
174
  assert_kind_of Excelx, oo
160
175
  end
161
176
  end
@@ -180,7 +195,7 @@ class TestRoo < Test::Unit::TestCase
180
195
 
181
196
  def test_sheets_openoffice
182
197
  if OPENOFFICE
183
- oo = Openoffice.new(File.join("test","numbers1.ods"))
198
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
184
199
  assert_equal ["Tabelle1","Name of Sheet 2","Sheet3","Sheet4","Sheet5"], oo.sheets
185
200
  assert_raise(RangeError) {
186
201
  oo.default_sheet = "no_sheet"
@@ -198,7 +213,7 @@ class TestRoo < Test::Unit::TestCase
198
213
 
199
214
  def test_sheets_gnumeric_ods
200
215
  if GNUMERIC_ODS
201
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
216
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
202
217
  assert_equal ["Tabelle1","Name of Sheet 2","Sheet3","Sheet4","Sheet5"], oo.sheets
203
218
  assert_raise(RangeError) {
204
219
  oo.default_sheet = "no_sheet"
@@ -216,7 +231,7 @@ class TestRoo < Test::Unit::TestCase
216
231
 
217
232
  def test_sheets_excel
218
233
  if EXCEL
219
- oo = Excel.new(File.join("test","numbers1.xls"))
234
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
220
235
  assert_equal ["Tabelle1","Name of Sheet 2","Sheet3","Sheet4","Sheet5"], oo.sheets
221
236
  assert_raise(RangeError) {
222
237
  oo.default_sheet = "no_sheet"
@@ -233,7 +248,7 @@ class TestRoo < Test::Unit::TestCase
233
248
 
234
249
  def test_sheets_excelx
235
250
  if EXCELX
236
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
251
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
237
252
  assert_equal ["Tabelle1","Name of Sheet 2","Sheet3","Sheet4","Sheet5"], oo.sheets
238
253
  assert_raise(RangeError) {
239
254
  oo.default_sheet = "no_sheet"
@@ -267,7 +282,7 @@ class TestRoo < Test::Unit::TestCase
267
282
 
268
283
  def test_cell_openoffice
269
284
  if OPENOFFICE
270
- oo = Openoffice.new(File.join("test","numbers1.ods"))
285
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
271
286
  oo.default_sheet = oo.sheets.first
272
287
  assert_equal 1, oo.cell(1,1)
273
288
  assert_equal 2, oo.cell(1,2)
@@ -306,7 +321,7 @@ class TestRoo < Test::Unit::TestCase
306
321
 
307
322
  def test_cell_gnumeric_ods
308
323
  if GNUMERIC_ODS
309
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
324
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
310
325
  oo.default_sheet = oo.sheets.first
311
326
  assert_equal 1, oo.cell(1,1)
312
327
  assert_equal 2, oo.cell(1,2)
@@ -345,7 +360,7 @@ class TestRoo < Test::Unit::TestCase
345
360
 
346
361
  def test_cell_excel
347
362
  if EXCEL
348
- oo = Excel.new(File.join("test","numbers1.xls"))
363
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
349
364
  oo.default_sheet = oo.sheets.first
350
365
  assert_equal 1, oo.cell(1,1)
351
366
  assert_equal 2, oo.cell(1,2)
@@ -384,7 +399,7 @@ class TestRoo < Test::Unit::TestCase
384
399
 
385
400
  def test_cell_excelx
386
401
  if EXCELX
387
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
402
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
388
403
  oo.default_sheet = oo.sheets.first
389
404
 
390
405
  assert_kind_of Float, oo.cell(1,1)
@@ -437,25 +452,19 @@ class TestRoo < Test::Unit::TestCase
437
452
  assert_equal 8, oo.cell(2,4)
438
453
  assert_equal 9, oo.cell(2,5)
439
454
  assert_equal "test", oo.cell(2,6)
440
- # assert_equal "string", oo.celltype(2,6)
441
455
  assert_equal :string, oo.celltype(2,6)
442
456
  assert_equal 11, oo.cell(2,7)
443
- # assert_equal "float", oo.celltype(2,7)
444
457
  assert_equal :float, oo.celltype(2,7), "Inhalt: --#{oo.cell(2,7)}--"
445
-
446
458
  assert_equal 10, oo.cell(4,1)
447
459
  assert_equal 11, oo.cell(4,2)
448
460
  assert_equal 12, oo.cell(4,3)
449
461
  assert_equal 13, oo.cell(4,4)
450
462
  assert_equal 14, oo.cell(4,5)
451
-
452
463
  assert_equal 10, oo.cell(4,'A')
453
464
  assert_equal 11, oo.cell(4,'B')
454
465
  assert_equal 12, oo.cell(4,'C')
455
466
  assert_equal 13, oo.cell(4,'D')
456
467
  assert_equal 14, oo.cell(4,'E')
457
-
458
- # assert_equal "date", oo.celltype(5,1)
459
468
  assert_equal :date, oo.celltype(5,1)
460
469
  assert_equal Date.new(1961,11,21), oo.cell(5,1)
461
470
  assert_equal "1961-11-21", oo.cell(5,1).to_s
@@ -465,17 +474,17 @@ class TestRoo < Test::Unit::TestCase
465
474
  def test_celltype
466
475
  ###
467
476
  if OPENOFFICE
468
- oo = Openoffice.new(File.join("test","numbers1.ods"))
477
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
469
478
  oo.default_sheet = oo.sheets.first
470
479
  assert_equal :string, oo.celltype(2,6)
471
480
  end
472
481
  if GNUMERIC_ODS
473
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
482
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
474
483
  oo.default_sheet = oo.sheets.first
475
484
  assert_equal :string, oo.celltype(2,6)
476
485
  end
477
486
  if EXCEL
478
- oo = Excel.new(File.join("test","numbers1.xls"))
487
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
479
488
  oo.default_sheet = oo.sheets.first
480
489
  assert_equal :string, oo.celltype(2,6)
481
490
  end
@@ -485,7 +494,7 @@ class TestRoo < Test::Unit::TestCase
485
494
  assert_equal :string, oo.celltype(2,6)
486
495
  end
487
496
  if EXCELX
488
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
497
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
489
498
  oo.default_sheet = oo.sheets.first
490
499
  assert_equal :string, oo.celltype(2,6)
491
500
  end
@@ -493,7 +502,7 @@ class TestRoo < Test::Unit::TestCase
493
502
 
494
503
  def test_cell_address
495
504
  if OPENOFFICE
496
- oo = Openoffice.new(File.join("test","numbers1.ods"))
505
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
497
506
  oo.default_sheet = oo.sheets.first
498
507
  assert_equal "tata", oo.cell(6,1)
499
508
  assert_equal "tata", oo.cell(6,'A')
@@ -518,7 +527,7 @@ class TestRoo < Test::Unit::TestCase
518
527
  end
519
528
 
520
529
  if GNUMERIC_ODS
521
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
530
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
522
531
  oo.default_sheet = oo.sheets.first
523
532
  assert_equal "tata", oo.cell(6,1)
524
533
  assert_equal "tata", oo.cell(6,'A')
@@ -543,7 +552,7 @@ class TestRoo < Test::Unit::TestCase
543
552
  end
544
553
 
545
554
  if EXCEL
546
- oo = Excel.new(File.join("test","numbers1.xls"))
555
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
547
556
  oo.default_sheet = oo.sheets.first
548
557
  assert_equal "tata", oo.cell(6,'A')
549
558
  assert_equal "tata", oo.cell(6,1)
@@ -570,7 +579,7 @@ class TestRoo < Test::Unit::TestCase
570
579
  end
571
580
 
572
581
  if EXCELX
573
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
582
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
574
583
  oo.default_sheet = oo.sheets.first
575
584
  assert_equal "tata", oo.cell(6,1)
576
585
  assert_equal "tata", oo.cell(6,'A')
@@ -626,11 +635,11 @@ class TestRoo < Test::Unit::TestCase
626
635
  # please note that "1.0" is returned even if it was created with OpenOffice V. 2.0
627
636
  def test_officeversion
628
637
  if OPENOFFICE
629
- oo = Openoffice.new(File.join("test","numbers1.ods"))
638
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
630
639
  assert_equal "1.0", oo.officeversion
631
640
  end
632
641
  if GNUMERIC_ODS
633
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
642
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
634
643
  assert_equal "1.0", oo.officeversion
635
644
  end
636
645
  if EXCEL
@@ -648,7 +657,7 @@ class TestRoo < Test::Unit::TestCase
648
657
  #TODO: inkonsequente Lieferung Fixnum/Float
649
658
  def test_rows
650
659
  if OPENOFFICE
651
- oo = Openoffice.new(File.join("test","numbers1.ods"))
660
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
652
661
  oo.default_sheet = oo.sheets.first
653
662
  assert_equal 41, oo.cell('a',12)
654
663
  assert_equal 42, oo.cell('b',12)
@@ -664,7 +673,7 @@ class TestRoo < Test::Unit::TestCase
664
673
  assert_equal ["einundvierzig", "zweiundvierzig", "dreiundvierzig", "vierundvierzig", "fuenfundvierzig"], oo.row(16)
665
674
  end
666
675
  if GNUMERIC_ODS
667
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
676
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
668
677
  oo.default_sheet = oo.sheets.first
669
678
  assert_equal 41, oo.cell('a',12)
670
679
  assert_equal 42, oo.cell('b',12)
@@ -680,7 +689,7 @@ class TestRoo < Test::Unit::TestCase
680
689
  assert_equal ["einundvierzig", "zweiundvierzig", "dreiundvierzig", "vierundvierzig", "fuenfundvierzig"], oo.row(16)
681
690
  end
682
691
  if EXCEL
683
- oo = Excel.new(File.join("test","numbers1.xls"))
692
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
684
693
  oo.default_sheet = oo.sheets.first
685
694
  assert_equal 41, oo.cell('a',12)
686
695
  assert_equal 42, oo.cell('b',12)
@@ -700,7 +709,7 @@ class TestRoo < Test::Unit::TestCase
700
709
  "fuenfundvierzig"], oo.row(16)
701
710
  end
702
711
  if EXCELX
703
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
712
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
704
713
  oo.default_sheet = oo.sheets.first
705
714
  assert_equal 41, oo.cell('a',12)
706
715
  assert_equal 42, oo.cell('b',12)
@@ -743,22 +752,22 @@ class TestRoo < Test::Unit::TestCase
743
752
 
744
753
  def test_last_row
745
754
  if OPENOFFICE
746
- oo = Openoffice.new(File.join("test","numbers1.ods"))
755
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
747
756
  oo.default_sheet = oo.sheets.first
748
757
  assert_equal 18, oo.last_row
749
758
  end
750
759
  if GNUMERIC_ODS
751
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
760
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
752
761
  oo.default_sheet = oo.sheets.first
753
762
  assert_equal 18, oo.last_row
754
763
  end
755
764
  if EXCEL
756
- oo = Excel.new(File.join("test","numbers1.xls"))
765
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
757
766
  oo.default_sheet = oo.sheets.first
758
767
  assert_equal 18, oo.last_row
759
768
  end
760
769
  if EXCELX
761
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
770
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
762
771
  oo.default_sheet = oo.sheets.first
763
772
  assert_equal 18, oo.last_row
764
773
  end
@@ -771,22 +780,22 @@ class TestRoo < Test::Unit::TestCase
771
780
 
772
781
  def test_last_column
773
782
  if OPENOFFICE
774
- oo = Openoffice.new(File.join("test","numbers1.ods"))
783
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
775
784
  oo.default_sheet = oo.sheets.first
776
785
  assert_equal 7, oo.last_column
777
786
  end
778
787
  if GNUMERIC_ODS
779
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
788
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
780
789
  oo.default_sheet = oo.sheets.first
781
790
  assert_equal 7, oo.last_column
782
791
  end
783
792
  if EXCEL
784
- oo = Excel.new(File.join("test","numbers1.xls"))
793
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
785
794
  oo.default_sheet = oo.sheets.first
786
795
  assert_equal 7, oo.last_column
787
796
  end
788
797
  if EXCELX
789
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
798
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
790
799
  oo.default_sheet = oo.sheets.first
791
800
  assert_equal 7, oo.last_column
792
801
  end
@@ -799,22 +808,22 @@ class TestRoo < Test::Unit::TestCase
799
808
 
800
809
  def test_last_column_as_letter
801
810
  if OPENOFFICE
802
- oo = Openoffice.new(File.join("test","numbers1.ods"))
811
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
803
812
  oo.default_sheet = oo.sheets.first
804
813
  assert_equal 'G', oo.last_column_as_letter
805
814
  end
806
815
  if GNUMERIC_ODS
807
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
816
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
808
817
  oo.default_sheet = oo.sheets.first
809
818
  assert_equal 'G', oo.last_column_as_letter
810
819
  end
811
820
  if EXCEL
812
- oo = Excel.new(File.join("test","numbers1.xls"))
821
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
813
822
  oo.default_sheet = 1 # oo.sheets.first
814
823
  assert_equal 'G', oo.last_column_as_letter
815
824
  end
816
825
  if EXCELX
817
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
826
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
818
827
  oo.default_sheet = oo.sheets.first
819
828
  assert_equal 'G', oo.last_column_as_letter
820
829
  end
@@ -827,22 +836,22 @@ class TestRoo < Test::Unit::TestCase
827
836
 
828
837
  def test_first_row
829
838
  if OPENOFFICE
830
- oo = Openoffice.new(File.join("test","numbers1.ods"))
839
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
831
840
  oo.default_sheet = oo.sheets.first
832
841
  assert_equal 1, oo.first_row
833
842
  end
834
843
  if GNUMERIC_ODS
835
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
844
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
836
845
  oo.default_sheet = oo.sheets.first
837
846
  assert_equal 1, oo.first_row
838
847
  end
839
848
  if EXCEL
840
- oo = Excel.new(File.join("test","numbers1.xls"))
849
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
841
850
  oo.default_sheet = 1 # oo.sheets.first
842
851
  assert_equal 1, oo.first_row
843
852
  end
844
853
  if EXCELX
845
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
854
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
846
855
  oo.default_sheet = oo.sheets.first
847
856
  assert_equal 1, oo.first_row
848
857
  end
@@ -855,22 +864,22 @@ class TestRoo < Test::Unit::TestCase
855
864
 
856
865
  def test_first_column
857
866
  if OPENOFFICE
858
- oo = Openoffice.new(File.join("test","numbers1.ods"))
867
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
859
868
  oo.default_sheet = oo.sheets.first
860
869
  assert_equal 1, oo.first_column
861
870
  end
862
871
  if GNUMERIC_ODS
863
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
872
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
864
873
  oo.default_sheet = oo.sheets.first
865
874
  assert_equal 1, oo.first_column
866
875
  end
867
876
  if EXCEL
868
- oo = Excel.new(File.join("test","numbers1.xls"))
877
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
869
878
  oo.default_sheet = 1 # oo.sheets.first
870
879
  assert_equal 1, oo.first_column
871
880
  end
872
881
  if EXCELX
873
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
882
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
874
883
  oo.default_sheet = oo.sheets.first
875
884
  assert_equal 1, oo.first_column
876
885
  end
@@ -887,7 +896,7 @@ class TestRoo < Test::Unit::TestCase
887
896
 
888
897
  def test_first_column_as_letter_openoffice
889
898
  if OPENOFFICE
890
- oo = Openoffice.new(File.join("test","numbers1.ods"))
899
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
891
900
  oo.default_sheet = oo.sheets.first
892
901
  assert_equal 'A', oo.first_column_as_letter
893
902
  end
@@ -895,7 +904,7 @@ class TestRoo < Test::Unit::TestCase
895
904
 
896
905
  def test_first_column_as_letter_gnumeric_ods
897
906
  if GNUMERIC_ODS
898
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
907
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
899
908
  oo.default_sheet = oo.sheets.first
900
909
  assert_equal 'A', oo.first_column_as_letter
901
910
  end
@@ -903,7 +912,7 @@ class TestRoo < Test::Unit::TestCase
903
912
 
904
913
  def test_first_column_as_letter_excel
905
914
  if EXCEL
906
- oo = Excel.new(File.join("test","numbers1.xls"))
915
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
907
916
  oo.default_sheet = 1 # oo.sheets.first
908
917
  assert_equal 'A', oo.first_column_as_letter
909
918
  end
@@ -911,7 +920,7 @@ class TestRoo < Test::Unit::TestCase
911
920
 
912
921
  def test_first_column_as_letter_excelx
913
922
  if EXCELX
914
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
923
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
915
924
  oo.default_sheet = oo.sheets.first
916
925
  assert_equal 'A', oo.first_column_as_letter
917
926
  end
@@ -927,7 +936,7 @@ class TestRoo < Test::Unit::TestCase
927
936
 
928
937
  def test_sheetname
929
938
  if OPENOFFICE
930
- oo = Openoffice.new(File.join("test","numbers1.ods"))
939
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
931
940
  oo.default_sheet = "Name of Sheet 2"
932
941
  assert_equal 'I am sheet 2', oo.cell('C',5)
933
942
  assert_raise(RangeError) { oo.default_sheet = "non existing sheet name" }
@@ -941,7 +950,7 @@ class TestRoo < Test::Unit::TestCase
941
950
  assert_raise(RangeError) { dummy = oo.to_yaml({},1,1,1,1,"non existing sheet name")}
942
951
  end
943
952
  if GNUMERIC_ODS
944
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
953
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
945
954
  oo.default_sheet = "Name of Sheet 2"
946
955
  assert_equal 'I am sheet 2', oo.cell('C',5)
947
956
  assert_raise(RangeError) {
@@ -958,7 +967,7 @@ class TestRoo < Test::Unit::TestCase
958
967
  assert_raise(RangeError) { dummy = oo.to_yaml({},1,1,1,1,"non existing sheet name")}
959
968
  end
960
969
  if EXCEL
961
- oo = Excel.new(File.join("test","numbers1.xls"))
970
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
962
971
  oo.default_sheet = "Name of Sheet 2"
963
972
  assert_equal 'I am sheet 2', oo.cell('C',5)
964
973
  assert_raise(RangeError) {
@@ -975,7 +984,7 @@ class TestRoo < Test::Unit::TestCase
975
984
  assert_raise(RangeError) { dummy = oo.to_yaml({},1,1,1,1,"non existing sheet name")}
976
985
  end
977
986
  if EXCELX
978
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
987
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
979
988
  oo.default_sheet = "Name of Sheet 2"
980
989
  assert_equal 'I am sheet 2', oo.cell('C',5)
981
990
  assert_raise(RangeError) {
@@ -1013,7 +1022,7 @@ class TestRoo < Test::Unit::TestCase
1013
1022
 
1014
1023
  def test_boundaries
1015
1024
  if OPENOFFICE
1016
- oo = Openoffice.new(File.join("test","numbers1.ods"))
1025
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
1017
1026
  oo.default_sheet = "Name of Sheet 2"
1018
1027
  assert_equal 2, oo.first_column
1019
1028
  assert_equal 'B', oo.first_column_as_letter
@@ -1022,7 +1031,7 @@ class TestRoo < Test::Unit::TestCase
1022
1031
  assert_equal 14, oo.last_row
1023
1032
  end
1024
1033
  if GNUMERIC_ODS
1025
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
1034
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
1026
1035
  oo.default_sheet = "Name of Sheet 2"
1027
1036
  assert_equal 2, oo.first_column
1028
1037
  assert_equal 'B', oo.first_column_as_letter
@@ -1032,7 +1041,7 @@ class TestRoo < Test::Unit::TestCase
1032
1041
  end
1033
1042
  if EXCEL
1034
1043
  #-- Excel
1035
- oo = Excel.new(File.join("test","numbers1.xls"))
1044
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
1036
1045
  oo.default_sheet = 2 # "Name of Sheet 2"
1037
1046
  assert_equal 2, oo.first_column
1038
1047
  assert_equal 'B', oo.first_column_as_letter
@@ -1041,7 +1050,7 @@ class TestRoo < Test::Unit::TestCase
1041
1050
  assert_equal 14, oo.last_row
1042
1051
  end
1043
1052
  if EXCELX
1044
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
1053
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
1045
1054
  oo.default_sheet = "Name of Sheet 2"
1046
1055
  assert_equal 2, oo.first_column
1047
1056
  assert_equal 'B', oo.first_column_as_letter
@@ -1053,7 +1062,7 @@ class TestRoo < Test::Unit::TestCase
1053
1062
 
1054
1063
  def test_multiple_letters
1055
1064
  if OPENOFFICE
1056
- oo = Openoffice.new(File.join("test","numbers1.ods"))
1065
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
1057
1066
  oo.default_sheet = "Sheet3"
1058
1067
  assert_equal "i am AA", oo.cell('AA',1)
1059
1068
  assert_equal "i am AB", oo.cell('AB',1)
@@ -1062,7 +1071,7 @@ class TestRoo < Test::Unit::TestCase
1062
1071
  assert_equal "i am BA", oo.cell(1,'BA')
1063
1072
  end
1064
1073
  if GNUMERIC_ODS
1065
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
1074
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
1066
1075
  oo.default_sheet = "Sheet3"
1067
1076
  assert_equal "i am AA", oo.cell('AA',1)
1068
1077
  assert_equal "i am AB", oo.cell('AB',1)
@@ -1071,7 +1080,7 @@ class TestRoo < Test::Unit::TestCase
1071
1080
  assert_equal "i am BA", oo.cell(1,'BA')
1072
1081
  end
1073
1082
  if EXCEL
1074
- oo = Excel.new(File.join("test","numbers1.xls"))
1083
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
1075
1084
  oo.default_sheet = 3 # "Sheet3"
1076
1085
  assert_equal "i am AA", oo.cell('AA',1)
1077
1086
  assert_equal "i am AB", oo.cell('AB',1)
@@ -1080,7 +1089,7 @@ class TestRoo < Test::Unit::TestCase
1080
1089
  assert_equal "i am BA", oo.cell(1,'BA')
1081
1090
  end
1082
1091
  if EXCELX
1083
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
1092
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
1084
1093
  oo.default_sheet = "Sheet3"
1085
1094
  assert_equal "i am AA", oo.cell('AA',1)
1086
1095
  assert_equal "i am AB", oo.cell('AB',1)
@@ -1092,7 +1101,7 @@ class TestRoo < Test::Unit::TestCase
1092
1101
 
1093
1102
  def test_argument_error
1094
1103
  if EXCEL
1095
- oo = Excel.new(File.join("test","numbers1.xls"))
1104
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
1096
1105
  before Date.new(2007,7,20) do
1097
1106
  assert_raise(ArgumentError) {
1098
1107
  #oo.default_sheet = "first sheet"
@@ -1109,28 +1118,28 @@ class TestRoo < Test::Unit::TestCase
1109
1118
 
1110
1119
  def test_empty_eh
1111
1120
  if OPENOFFICE #-- OpenOffice
1112
- oo = Openoffice.new(File.join("test","numbers1.ods"))
1121
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
1113
1122
  oo.default_sheet = oo.sheets.first
1114
1123
  assert oo.empty?('a',14)
1115
1124
  assert ! oo.empty?('a',15)
1116
1125
  assert oo.empty?('a',20)
1117
1126
  end
1118
1127
  if GNUMERIC_ODS
1119
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
1128
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
1120
1129
  oo.default_sheet = oo.sheets.first
1121
1130
  assert oo.empty?('a',14)
1122
1131
  assert ! oo.empty?('a',15)
1123
1132
  assert oo.empty?('a',20)
1124
1133
  end
1125
1134
  if EXCEL
1126
- oo = Excel.new(File.join("test","numbers1.xls"))
1135
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
1127
1136
  oo.default_sheet = 1
1128
1137
  assert oo.empty?('a',14)
1129
1138
  assert ! oo.empty?('a',15)
1130
1139
  assert oo.empty?('a',20)
1131
1140
  end
1132
1141
  if EXCELX
1133
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
1142
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
1134
1143
  oo.default_sheet = oo.sheets.first
1135
1144
  assert oo.empty?('a',14)
1136
1145
  assert ! oo.empty?('a',15)
@@ -1140,11 +1149,11 @@ class TestRoo < Test::Unit::TestCase
1140
1149
 
1141
1150
  def test_writeopenoffice
1142
1151
  if OPENOFFICEWRITE
1143
- File.cp(File.join("test","numbers1.ods"),
1144
- File.join("test","numbers2.ods"))
1145
- File.cp(File.join("test","numbers2.ods"),
1146
- File.join("test","bak_numbers2.ods"))
1147
- oo = Openoffice.new(File.join("test","numbers2.ods"))
1152
+ File.cp(File.join(TESTDIR,"numbers1.ods"),
1153
+ File.join(TESTDIR,"numbers2.ods"))
1154
+ File.cp(File.join(TESTDIR,"numbers2.ods"),
1155
+ File.join(TESTDIR,"bak_numbers2.ods"))
1156
+ oo = Openoffice.new(File.join(TESTDIR,"numbers2.ods"))
1148
1157
  oo.default_sheet = oo.sheets.first
1149
1158
  oo.first_row.upto(oo.last_row) {|y|
1150
1159
  oo.first_column.upto(oo.last_column) {|x|
@@ -1156,8 +1165,8 @@ class TestRoo < Test::Unit::TestCase
1156
1165
  }
1157
1166
  oo.save
1158
1167
 
1159
- oo1 = Openoffice.new(File.join("test","numbers2.ods"))
1160
- oo2 = Openoffice.new(File.join("test","bak_numbers2.ods"))
1168
+ oo1 = Openoffice.new(File.join(TESTDIR,"numbers2.ods"))
1169
+ oo2 = Openoffice.new(File.join(TESTDIR,"bak_numbers2.ods"))
1161
1170
  #p oo2.to_s
1162
1171
  assert_equal 999, oo2.cell('a',1), oo2.cell('a',1)
1163
1172
  assert_equal oo2.cell('a',1) + 7, oo1.cell('a',1)
@@ -1170,14 +1179,14 @@ class TestRoo < Test::Unit::TestCase
1170
1179
  assert_equal oo2.cell('d',2)+7, oo1.cell('d',2)
1171
1180
  assert_equal oo2.cell('e',2)+7, oo1.cell('e',2)
1172
1181
 
1173
- File.cp(File.join("test","bak_numbers2.ods"),
1174
- File.join("test","numbers2.ods"))
1182
+ File.cp(File.join(TESTDIR,"bak_numbers2.ods"),
1183
+ File.join(TESTDIR,"numbers2.ods"))
1175
1184
  end
1176
1185
  end
1177
1186
 
1178
1187
  def test_reload
1179
1188
  if OPENOFFICE
1180
- oo = Openoffice.new(File.join("test","numbers1.ods"))
1189
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
1181
1190
  oo.default_sheet = oo.sheets.first
1182
1191
  assert_equal 1, oo.cell(1,1)
1183
1192
 
@@ -1185,7 +1194,7 @@ class TestRoo < Test::Unit::TestCase
1185
1194
  assert_equal 1, oo.cell(1,1)
1186
1195
  end
1187
1196
  if GNUMERIC_ODS
1188
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
1197
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
1189
1198
  oo.default_sheet = oo.sheets.first
1190
1199
  assert_equal 1, oo.cell(1,1)
1191
1200
 
@@ -1193,7 +1202,7 @@ class TestRoo < Test::Unit::TestCase
1193
1202
  assert_equal 1, oo.cell(1,1)
1194
1203
  end
1195
1204
  if EXCEL
1196
- oo = Excel.new(File.join("test","numbers1.xls"))
1205
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
1197
1206
  oo.default_sheet = 1 # oo.sheets.first
1198
1207
  assert_equal 1, oo.cell(1,1)
1199
1208
 
@@ -1201,7 +1210,7 @@ class TestRoo < Test::Unit::TestCase
1201
1210
  assert_equal 1, oo.cell(1,1)
1202
1211
  end
1203
1212
  if EXCELX
1204
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
1213
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
1205
1214
  oo.default_sheet = oo.sheets.first
1206
1215
  assert_equal 1, oo.cell(1,1)
1207
1216
 
@@ -1212,7 +1221,7 @@ class TestRoo < Test::Unit::TestCase
1212
1221
 
1213
1222
  def test_bug_contiguous_cells
1214
1223
  if OPENOFFICE
1215
- oo = Openoffice.new(File.join("test","numbers1.ods"))
1224
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
1216
1225
  oo.default_sheet = "Sheet4"
1217
1226
  assert_equal Date.new(2007,06,16), oo.cell('a',1)
1218
1227
  assert_equal 10, oo.cell('b',1)
@@ -1221,7 +1230,7 @@ class TestRoo < Test::Unit::TestCase
1221
1230
  assert_equal 10, oo.cell('e',1)
1222
1231
  end
1223
1232
  if GNUMERIC_ODS
1224
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
1233
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
1225
1234
  oo.default_sheet = "Sheet4"
1226
1235
  assert_equal Date.new(2007,06,16), oo.cell('a',1)
1227
1236
  assert_equal 10, oo.cell('b',1)
@@ -1241,7 +1250,7 @@ class TestRoo < Test::Unit::TestCase
1241
1250
 
1242
1251
  def test_bug_italo_ve
1243
1252
  if OPENOFFICE
1244
- oo = Openoffice.new(File.join("test","numbers1.ods"))
1253
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
1245
1254
  oo.default_sheet = "Sheet5"
1246
1255
  assert_equal 1, oo.cell('A',1)
1247
1256
  assert_equal 5, oo.cell('b',1)
@@ -1250,7 +1259,7 @@ class TestRoo < Test::Unit::TestCase
1250
1259
  assert_equal 3, oo.cell('a',3)
1251
1260
  end
1252
1261
  if OPENOFFICE
1253
- oo = Openoffice.new(File.join("test","numbers1.ods"))
1262
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
1254
1263
  oo.default_sheet = "Sheet5"
1255
1264
  assert_equal 1, oo.cell('A',1)
1256
1265
  assert_equal 5, oo.cell('b',1)
@@ -1259,7 +1268,7 @@ class TestRoo < Test::Unit::TestCase
1259
1268
  assert_equal 3, oo.cell('a',3)
1260
1269
  end
1261
1270
  if GNUMERIC_ODS
1262
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
1271
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
1263
1272
  oo.default_sheet = "Sheet5"
1264
1273
  assert_equal 1, oo.cell('A',1)
1265
1274
  assert_equal 5, oo.cell('b',1)
@@ -1268,7 +1277,7 @@ class TestRoo < Test::Unit::TestCase
1268
1277
  assert_equal 3, oo.cell('a',3)
1269
1278
  end
1270
1279
  if EXCEL
1271
- oo = Excel.new(File.join("test","numbers1.xls"))
1280
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
1272
1281
  oo.default_sheet = 5
1273
1282
  assert_equal 1, oo.cell('A',1)
1274
1283
  assert_equal 5, oo.cell('b',1)
@@ -1277,7 +1286,7 @@ class TestRoo < Test::Unit::TestCase
1277
1286
  assert_equal 3, oo.cell('a',3)
1278
1287
  end
1279
1288
  if EXCELX
1280
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
1289
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
1281
1290
  oo.default_sheet = "Sheet5" # oo.sheets[5-1]
1282
1291
  assert_equal 1, oo.cell('A',1)
1283
1292
  assert_equal 5, oo.cell('b',1)
@@ -1299,7 +1308,7 @@ class TestRoo < Test::Unit::TestCase
1299
1308
  #2008-01-30
1300
1309
  def test_italo_table
1301
1310
  local_only do
1302
- oo = Openoffice.new(File.join("test","simple_spreadsheet_from_italo.ods"))
1311
+ oo = Openoffice.new(File.join(TESTDIR,"simple_spreadsheet_from_italo.ods"))
1303
1312
  oo.default_sheet = oo.sheets.first
1304
1313
 
1305
1314
  assert_equal '1', oo.cell('A',1)
@@ -1361,7 +1370,7 @@ class TestRoo < Test::Unit::TestCase
1361
1370
  assert_equal "0.01:percentage",oo.cell(5, 2).to_s+":"+oo.celltype(5, 2).to_s
1362
1371
  assert_equal "0.01:percentage",oo.cell(5, 3).to_s+":"+oo.celltype(5, 3).to_s
1363
1372
 
1364
- oo = Excel.new(File.join("test","simple_spreadsheet_from_italo.xls"))
1373
+ oo = Excel.new(File.join(TESTDIR,"simple_spreadsheet_from_italo.xls"))
1365
1374
  oo.default_sheet = oo.sheets.first
1366
1375
 
1367
1376
  assert_equal '1', oo.cell('A',1)
@@ -1435,7 +1444,7 @@ class TestRoo < Test::Unit::TestCase
1435
1444
 
1436
1445
  def test_formula_openoffice
1437
1446
  if OPENOFFICE
1438
- oo = Openoffice.new(File.join("test","formula.ods"))
1447
+ oo = Openoffice.new(File.join(TESTDIR,"formula.ods"))
1439
1448
  oo.default_sheet = oo.sheets.first
1440
1449
  assert_equal 1, oo.cell('A',1)
1441
1450
  assert_equal 2, oo.cell('A',2)
@@ -1466,7 +1475,7 @@ class TestRoo < Test::Unit::TestCase
1466
1475
  def test_formula_excel
1467
1476
  if defined? excel_supports_formulas
1468
1477
  if EXCEL
1469
- oo = Excel.new(File.join("test","formula.xls"))
1478
+ oo = Excel.new(File.join(TESTDIR,"formula.xls"))
1470
1479
  oo.default_sheet = oo.sheets.first
1471
1480
  assert_equal 1, oo.cell('A',1)
1472
1481
  assert_equal 2, oo.cell('A',2)
@@ -1536,7 +1545,7 @@ class TestRoo < Test::Unit::TestCase
1536
1545
 
1537
1546
  def test_formula_excelx
1538
1547
  if EXCELX
1539
- oo = Excelx.new(File.join("test","formula.xlsx"))
1548
+ oo = Excelx.new(File.join(TESTDIR,"formula.xlsx"))
1540
1549
  oo.default_sheet = oo.sheets.first
1541
1550
  assert_equal 1, oo.cell('A',1)
1542
1551
  assert_equal 2, oo.cell('A',2)
@@ -1575,7 +1584,7 @@ class TestRoo < Test::Unit::TestCase
1575
1584
 
1576
1585
  def test_borders_sheets_openoffice
1577
1586
  if OPENOFFICE
1578
- oo = Openoffice.new(File.join("test","borders.ods"))
1587
+ oo = Openoffice.new(File.join(TESTDIR,"borders.ods"))
1579
1588
  oo.default_sheet = oo.sheets[1]
1580
1589
  assert_equal 6, oo.first_row
1581
1590
  assert_equal 11, oo.last_row
@@ -1598,7 +1607,7 @@ class TestRoo < Test::Unit::TestCase
1598
1607
 
1599
1608
  def test_borders_sheets_excel
1600
1609
  if EXCEL
1601
- oo = Excel.new(File.join("test","borders.xls"))
1610
+ oo = Excel.new(File.join(TESTDIR,"borders.xls"))
1602
1611
  oo.default_sheet = oo.sheets[1]
1603
1612
  assert_equal 6, oo.first_row
1604
1613
  assert_equal 11, oo.last_row
@@ -1621,7 +1630,7 @@ class TestRoo < Test::Unit::TestCase
1621
1630
 
1622
1631
  def test_borders_sheets_excelx
1623
1632
  if EXCELX
1624
- oo = Excelx.new(File.join("test","borders.xlsx"))
1633
+ oo = Excelx.new(File.join(TESTDIR,"borders.xlsx"))
1625
1634
  oo.default_sheet = oo.sheets[1]
1626
1635
  assert_equal 6, oo.first_row
1627
1636
  assert_equal 11, oo.last_row
@@ -1679,7 +1688,7 @@ class TestRoo < Test::Unit::TestCase
1679
1688
 
1680
1689
  def test_to_yaml
1681
1690
  if OPENOFFICE
1682
- oo = Openoffice.new(File.join("test","numbers1.ods"))
1691
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
1683
1692
  oo.default_sheet = oo.sheets.first
1684
1693
  assert_equal "--- \n"+yaml_entry(5,1,"date","1961-11-21"), oo.to_yaml({}, 5,1,5,1)
1685
1694
  assert_equal "--- \n"+yaml_entry(8,3,"string","thisisc8"), oo.to_yaml({}, 8,3,8,3)
@@ -1702,7 +1711,7 @@ class TestRoo < Test::Unit::TestCase
1702
1711
  #example: puts oo.to_yaml({"probe" => "bodenproben_2007-06-30"}, 12,3)
1703
1712
  end
1704
1713
  if EXCEL
1705
- oo = Excel.new(File.join("test","numbers1.xls"))
1714
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
1706
1715
  oo.default_sheet = 1
1707
1716
  assert_equal "--- \n"+yaml_entry(5,1,"date","1961-11-21"), oo.to_yaml({}, 5,1,5,1)
1708
1717
  assert_equal "--- \n"+yaml_entry(8,3,"string","thisisc8"), oo.to_yaml({}, 8,3,8,3)
@@ -1723,7 +1732,7 @@ class TestRoo < Test::Unit::TestCase
1723
1732
  yaml_entry(16,5,"string","fuenfundvierzig"), oo.to_yaml({}, 12,3)
1724
1733
  end
1725
1734
  if EXCELX
1726
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
1735
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
1727
1736
  oo.default_sheet = oo.sheets.first
1728
1737
  assert_equal "--- \n"+yaml_entry(5,1,"date","1961-11-21"), oo.to_yaml({}, 5,1,5,1)
1729
1738
  assert_equal "--- \n"+yaml_entry(8,3,"string","thisisc8"), oo.to_yaml({}, 8,3,8,3)
@@ -1849,7 +1858,7 @@ class TestRoo < Test::Unit::TestCase
1849
1858
  #end
1850
1859
 
1851
1860
  #def test_dsl
1852
- # s = Openoffice.new(File.join("test","numbers1.ods"))
1861
+ # s = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
1853
1862
  # s.default_sheet = s.sheets.first
1854
1863
  #
1855
1864
  # s.set 'a',1, 5
@@ -1862,8 +1871,8 @@ class TestRoo < Test::Unit::TestCase
1862
1871
  # end
1863
1872
 
1864
1873
  #def test_create_spreadsheet1
1865
- # name = File.join('test','createdspreadsheet.ods')
1866
- # rm(name) if File.exists?(File.join('test','createdspreadsheet.ods'))
1874
+ # name = File.join(TESTDIR,'createdspreadsheet.ods')
1875
+ # rm(name) if File.exists?(File.join(TESTDIR,'createdspreadsheet.ods'))
1867
1876
  # # anlegen, falls noch nicht existierend
1868
1877
  # s = Openoffice.new(name,true)
1869
1878
  # assert File.exists?(name)
@@ -1871,14 +1880,14 @@ class TestRoo < Test::Unit::TestCase
1871
1880
 
1872
1881
  #def test_create_spreadsheet2
1873
1882
  # # anlegen, falls noch nicht existierend
1874
- # s = Openoffice.new(File.join("test","createdspreadsheet.ods"),true)
1883
+ # s = Openoffice.new(File.join(TESTDIR,"createdspreadsheet.ods"),true)
1875
1884
  # s.set 'a',1,42
1876
1885
  # s.set 'b',1,43
1877
1886
  # s.set 'c',1,44
1878
1887
  # s.save
1879
1888
  #
1880
1889
  # #after Date.new(2007,7,3) do
1881
- # # t = Openoffice.new(File.join("test","createdspreadsheet.ods"))
1890
+ # # t = Openoffice.new(File.join(TESTDIR,"createdspreadsheet.ods"))
1882
1891
  # # assert_equal 42, t.cell(1,'a')
1883
1892
  # # assert_equal 43, t.cell('b',1)
1884
1893
  # # assert_equal 44, t.cell('c',3)
@@ -1887,7 +1896,7 @@ class TestRoo < Test::Unit::TestCase
1887
1896
 
1888
1897
  def test_only_one_sheet
1889
1898
  if OPENOFFICE
1890
- oo = Openoffice.new(File.join("test","only_one_sheet.ods"))
1899
+ oo = Openoffice.new(File.join(TESTDIR,"only_one_sheet.ods"))
1891
1900
  # oo.default_sheet = oo.sheets.first
1892
1901
  assert_equal 42, oo.cell('B',4)
1893
1902
  assert_equal 43, oo.cell('C',4)
@@ -1898,7 +1907,7 @@ class TestRoo < Test::Unit::TestCase
1898
1907
  assert_equal 44, oo.cell('D',4)
1899
1908
  end
1900
1909
  if EXCEL
1901
- oo = Excel.new(File.join("test","only_one_sheet.xls"))
1910
+ oo = Excel.new(File.join(TESTDIR,"only_one_sheet.xls"))
1902
1911
  # oo.default_sheet = oo.sheets.first
1903
1912
  assert_equal 42, oo.cell('B',4)
1904
1913
  assert_equal 43, oo.cell('C',4)
@@ -1909,7 +1918,7 @@ class TestRoo < Test::Unit::TestCase
1909
1918
  assert_equal 44, oo.cell('D',4)
1910
1919
  end
1911
1920
  if EXCELX
1912
- oo = Excelx.new(File.join("test","only_one_sheet.xlsx"))
1921
+ oo = Excelx.new(File.join(TESTDIR,"only_one_sheet.xlsx"))
1913
1922
  # oo.default_sheet = oo.sheets.first
1914
1923
  assert_equal 42, oo.cell('B',4)
1915
1924
  assert_equal 43, oo.cell('C',4)
@@ -1938,6 +1947,7 @@ class TestRoo < Test::Unit::TestCase
1938
1947
  if ONLINE
1939
1948
  url = 'http://stiny-leonhard.de/bode-v1.xls.zip'
1940
1949
  excel = Excel.new(url, :zip)
1950
+ excel.default_sheet = excel.sheets.first
1941
1951
  assert_equal 'ist "e" im Nenner von H(s)', excel.cell('b', 5)
1942
1952
  excel.remove_tmp # don't forget to remove the temporary files
1943
1953
  end
@@ -1975,7 +1985,7 @@ class TestRoo < Test::Unit::TestCase
1975
1985
  after Date.new(2009,1,10) do
1976
1986
  if EXCEL
1977
1987
  $log.level = Logger::DEBUG
1978
- excel = Excel.new(File.join("test","bode-v1.xls.zip"), :zip)
1988
+ excel = Excel.new(File.join(TESTDIR,"bode-v1.xls.zip"), :zip)
1979
1989
  assert excel
1980
1990
  # muss Fehler bringen, weil kein default_sheet gesetzt wurde
1981
1991
  assert_raises (ArgumentError) {
@@ -1994,7 +2004,7 @@ class TestRoo < Test::Unit::TestCase
1994
2004
  if EXCELX
1995
2005
  after Date.new(2999,7,30) do
1996
2006
  # diese Datei gibt es noch nicht gezippt
1997
- excel = Excelx.new(File.join("test","bode-v1.xlsx.zip"), :zip)
2007
+ excel = Excelx.new(File.join(TESTDIR,"bode-v1.xlsx.zip"), :zip)
1998
2008
  assert excel
1999
2009
  assert_raises (ArgumentError) {
2000
2010
  assert_equal 'ist "e" im Nenner von H(s)', excel.cell('b', 5)
@@ -2008,7 +2018,7 @@ class TestRoo < Test::Unit::TestCase
2008
2018
 
2009
2019
  def test_openoffice_zipped
2010
2020
  if OPENOFFICE
2011
- oo = Openoffice.new(File.join("test","bode-v1.ods.zip"), :zip)
2021
+ oo = Openoffice.new(File.join(TESTDIR,"bode-v1.ods.zip"), :zip)
2012
2022
  assert oo
2013
2023
  # muss Fehler bringen, weil kein default_sheet gesetzt wurde
2014
2024
  assert_raises (ArgumentError) {
@@ -2023,7 +2033,7 @@ class TestRoo < Test::Unit::TestCase
2023
2033
 
2024
2034
  def test_bug_ric
2025
2035
  if OPENOFFICE
2026
- oo = Openoffice.new(File.join("test","ric.ods"))
2036
+ oo = Openoffice.new(File.join(TESTDIR,"ric.ods"))
2027
2037
  oo.default_sheet = oo.sheets.first
2028
2038
  assert oo.empty?('A',1)
2029
2039
  assert oo.empty?('B',1)
@@ -2091,14 +2101,14 @@ class TestRoo < Test::Unit::TestCase
2091
2101
 
2092
2102
  def test_mehrteilig
2093
2103
  if OPENOFFICE
2094
- oo = Openoffice.new(File.join("test","Bibelbund1.ods"))
2104
+ oo = Openoffice.new(File.join(TESTDIR,"Bibelbund1.ods"))
2095
2105
  oo.default_sheet = oo.sheets.first
2096
2106
  assert_equal "Tagebuch des Sekret\303\244rs. Letzte Tagung 15./16.11.75 Schweiz", oo.cell(45,'A')
2097
2107
  end
2098
2108
  #if EXCELX
2099
2109
  # after Date.new(2008,6,1) do
2100
2110
  # #Datei gibt es noch nicht
2101
- # oo = Excelx.new(File.join("test","Bibelbund1.xlsx"))
2111
+ # oo = Excelx.new(File.join(TESTDIR,"Bibelbund1.xlsx"))
2102
2112
  # oo.default_sheet = oo.sheets.first
2103
2113
  # assert_equal "Tagebuch des Sekret\303\244rs. Letzte Tagung 15./16.11.75 Schweiz", oo.cell(45,'A')
2104
2114
  # end
@@ -2111,7 +2121,7 @@ class TestRoo < Test::Unit::TestCase
2111
2121
  assert_nothing_raised(Timeout::Error) {
2112
2122
  Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
2113
2123
  File.delete_if_exist("/tmp/Bibelbund.csv")
2114
- oo = Openoffice.new(File.join("test","Bibelbund.ods"))
2124
+ oo = Openoffice.new(File.join(TESTDIR,"Bibelbund.ods"))
2115
2125
  oo.default_sheet = oo.sheets.first
2116
2126
  assert_equal "Tagebuch des Sekret\303\244rs. Letzte Tagung 15./16.11.75 Schweiz", oo.cell(45,'A')
2117
2127
  assert_equal "Tagebuch des Sekret\303\244rs. Nachrichten aus Chile", oo.cell(46,'A')
@@ -2131,7 +2141,7 @@ class TestRoo < Test::Unit::TestCase
2131
2141
  assert_nothing_raised(Timeout::Error) {
2132
2142
  Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
2133
2143
  File.delete_if_exist("/tmp/Bibelbund.csv")
2134
- oo = Excel.new(File.join("test","Bibelbund.xls"))
2144
+ oo = Excel.new(File.join(TESTDIR,"Bibelbund.xls"))
2135
2145
  oo.default_sheet = oo.sheets.first
2136
2146
  assert oo.to_csv("/tmp/Bibelbund.csv")
2137
2147
  assert File.exists?("/tmp/Bibelbund.csv")
@@ -2149,7 +2159,7 @@ class TestRoo < Test::Unit::TestCase
2149
2159
  assert_nothing_raised(Timeout::Error) {
2150
2160
  Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
2151
2161
  File.delete_if_exist("/tmp/Bibelbund.csv")
2152
- oo = Excelx.new(File.join("test","Bibelbund.xlsx"))
2162
+ oo = Excelx.new(File.join(TESTDIR,"Bibelbund.xlsx"))
2153
2163
  oo.default_sheet = oo.sheets.first
2154
2164
  assert oo.to_csv("/tmp/Bibelbund.csv")
2155
2165
  assert File.exists?("/tmp/Bibelbund.csv")
@@ -2185,7 +2195,7 @@ class TestRoo < Test::Unit::TestCase
2185
2195
  #assert_nothing_raised(Timeout::Error) {
2186
2196
  Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
2187
2197
  File.delete_if_exist("/tmp/numbers1.csv")
2188
- oo = Openoffice.new(File.join("test","numbers1.ods"))
2198
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
2189
2199
 
2190
2200
 
2191
2201
  # bug?, 2008-01-15 from Troy Davis
@@ -2208,7 +2218,7 @@ class TestRoo < Test::Unit::TestCase
2208
2218
  #assert_nothing_raised(Timeout::Error) {
2209
2219
  Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
2210
2220
  File.delete_if_exist("/tmp/numbers1_excel.csv")
2211
- oo = Excel.new(File.join("test","numbers1.xls"))
2221
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
2212
2222
 
2213
2223
  # bug?, 2008-01-15 from Troy Davis
2214
2224
  assert oo.to_csv("/tmp/numbers1_excel.csv",oo.sheets.first)
@@ -2229,7 +2239,7 @@ class TestRoo < Test::Unit::TestCase
2229
2239
  #assert_nothing_raised(Timeout::Error) {
2230
2240
  Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
2231
2241
  File.delete_if_exist("/tmp/numbers1.csv")
2232
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
2242
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
2233
2243
 
2234
2244
  # bug?, 2008-01-15 from Troy Davis
2235
2245
  assert oo.to_csv("/tmp/numbers1.csv",oo.sheets.first)
@@ -2256,12 +2266,12 @@ class TestRoo < Test::Unit::TestCase
2256
2266
  oo.default_sheet = oo.sheets.first
2257
2267
  assert oo.to_csv("/tmp/numbers1.csv")
2258
2268
  assert File.exists?("/tmp/numbers1.csv")
2259
- assert_equal "", `diff test/numbers1.csv /tmp/numbers1.csv`
2269
+ assert_equal "", `diff #{File.join(TESTDIR,"numbers1.csv")} /tmp/numbers1.csv`
2260
2270
 
2261
2271
  # bug?, 2008-01-15 from Troy Davis
2262
2272
  assert oo.to_csv("/tmp/numbers1.csv",oo.sheets.first)
2263
2273
  assert File.exists?("/tmp/numbers1.csv")
2264
- assert_equal "", `diff test/numbers1.csv /tmp/numbers1.csv`
2274
+ assert_equal "", `diff #{File.join(TESTDIR,"numbers1.csv")} /tmp/numbers1.csv`
2265
2275
 
2266
2276
  end # Timeout
2267
2277
  #} # nothing_raised
@@ -2270,7 +2280,7 @@ class TestRoo < Test::Unit::TestCase
2270
2280
 
2271
2281
  def test_bug_mehrere_datum
2272
2282
  if OPENOFFICE
2273
- oo = Openoffice.new(File.join("test","numbers1.ods"))
2283
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
2274
2284
  oo.default_sheet = 'Sheet5'
2275
2285
  assert_equal :date, oo.celltype('A',4)
2276
2286
  assert_equal :date, oo.celltype('B',4)
@@ -2305,7 +2315,7 @@ class TestRoo < Test::Unit::TestCase
2305
2315
  end # Openoffice
2306
2316
 
2307
2317
  if EXCEL
2308
- oo = Excel.new(File.join("test","numbers1.xls"))
2318
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
2309
2319
  oo.default_sheet = 'Sheet5'
2310
2320
  assert_equal :date, oo.celltype('A',4)
2311
2321
  assert_equal :date, oo.celltype('B',4)
@@ -2339,7 +2349,7 @@ class TestRoo < Test::Unit::TestCase
2339
2349
  assert_equal "ABC", oo.cell('E',6)
2340
2350
  end # Excel
2341
2351
  if EXCELX
2342
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
2352
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
2343
2353
  oo.default_sheet = 'Sheet5'
2344
2354
  assert_equal :date, oo.celltype('A',4)
2345
2355
  assert_equal :date, oo.celltype('B',4)
@@ -2376,7 +2386,7 @@ class TestRoo < Test::Unit::TestCase
2376
2386
 
2377
2387
  def test_multiple_sheets
2378
2388
  if OPENOFFICE
2379
- oo = Openoffice.new(File.join("test","numbers1.ods"))
2389
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
2380
2390
  2.times do
2381
2391
  oo.default_sheet = "Tabelle1"
2382
2392
  assert_equal 1, oo.cell(1,1)
@@ -2420,7 +2430,7 @@ class TestRoo < Test::Unit::TestCase
2420
2430
 
2421
2431
  if EXCEL
2422
2432
  $debug = true
2423
- oo = Excel.new(File.join("test","numbers1.xls"))
2433
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
2424
2434
  2.times do
2425
2435
  oo.default_sheet = "Tabelle1"
2426
2436
  assert_equal 1, oo.cell(1,1)
@@ -2503,7 +2513,7 @@ class TestRoo < Test::Unit::TestCase
2503
2513
  end
2504
2514
  end
2505
2515
  if EXCELX
2506
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
2516
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
2507
2517
  2.times do
2508
2518
  oo.default_sheet = "Tabelle1"
2509
2519
  assert_equal 1, oo.cell(1,1)
@@ -2548,7 +2558,7 @@ class TestRoo < Test::Unit::TestCase
2548
2558
 
2549
2559
  def test_bug_empty_sheet_openoffice
2550
2560
  if OPENOFFICE
2551
- oo = Openoffice.new(File.join("test","formula.ods"))
2561
+ oo = Openoffice.new(File.join(TESTDIR,"formula.ods"))
2552
2562
  oo.default_sheet = 'Sheet3' # is an empty sheet
2553
2563
  assert_nothing_raised(NoMethodError) {
2554
2564
  oo.to_csv(File.join("/","tmp","emptysheet.csv"))
@@ -2559,7 +2569,7 @@ class TestRoo < Test::Unit::TestCase
2559
2569
 
2560
2570
  def test_bug_empty_sheet_excelx
2561
2571
  if EXCELX
2562
- oo = Excelx.new(File.join("test","formula.xlsx"))
2572
+ oo = Excelx.new(File.join(TESTDIR,"formula.xlsx"))
2563
2573
  oo.default_sheet = 'Sheet3' # is an empty sheet
2564
2574
  assert_nothing_raised(NoMethodError) {
2565
2575
  oo.to_csv(File.join("/","tmp","emptysheet.csv"))
@@ -2572,7 +2582,7 @@ class TestRoo < Test::Unit::TestCase
2572
2582
  if LONG_RUN
2573
2583
  if OPENOFFICE
2574
2584
  Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
2575
- oo = Openoffice.new(File.join("test","Bibelbund.ods"))
2585
+ oo = Openoffice.new(File.join(TESTDIR,"Bibelbund.ods"))
2576
2586
  oo.default_sheet = oo.sheets.first
2577
2587
  rec = oo.find 20
2578
2588
  assert rec
@@ -2593,7 +2603,7 @@ class TestRoo < Test::Unit::TestCase
2593
2603
  if LONG_RUN
2594
2604
  if EXCEL
2595
2605
  Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
2596
- oo = Excel.new(File.join("test","Bibelbund.xls"))
2606
+ oo = Excel.new(File.join(TESTDIR,"Bibelbund.xls"))
2597
2607
  oo.default_sheet = oo.sheets.first
2598
2608
  rec = oo.find 20
2599
2609
  assert rec
@@ -2613,7 +2623,7 @@ class TestRoo < Test::Unit::TestCase
2613
2623
  if LONG_RUN
2614
2624
  if EXCEL
2615
2625
  Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
2616
- oo = Excelx.new(File.join("test","Bibelbund.xlsx"))
2626
+ oo = Excelx.new(File.join(TESTDIR,"Bibelbund.xlsx"))
2617
2627
  oo.default_sheet = oo.sheets.first
2618
2628
  rec = oo.find 20
2619
2629
  assert rec
@@ -2629,7 +2639,7 @@ class TestRoo < Test::Unit::TestCase
2629
2639
 
2630
2640
  def test_find_by_row_openoffice
2631
2641
  if OPENOFFICE
2632
- oo = Openoffice.new(File.join("test","numbers1.ods"))
2642
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
2633
2643
  oo.default_sheet = oo.sheets.first
2634
2644
  oo.header_line = nil
2635
2645
  rec = oo.find 16
@@ -2647,7 +2657,7 @@ class TestRoo < Test::Unit::TestCase
2647
2657
 
2648
2658
  def test_find_by_row_excel
2649
2659
  if EXCEL
2650
- oo = Excel.new(File.join("test","numbers1.xls"))
2660
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
2651
2661
  oo.default_sheet = oo.sheets.first
2652
2662
  oo.header_line = nil
2653
2663
  rec = oo.find 16
@@ -2663,7 +2673,7 @@ class TestRoo < Test::Unit::TestCase
2663
2673
 
2664
2674
  def test_find_by_row_excelx
2665
2675
  if EXCELX
2666
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
2676
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
2667
2677
  oo.default_sheet = oo.sheets.first
2668
2678
  oo.header_line = nil
2669
2679
  rec = oo.find 16
@@ -2716,7 +2726,7 @@ class TestRoo < Test::Unit::TestCase
2716
2726
  if OPENOFFICE
2717
2727
  assert_nothing_raised(Timeout::Error) {
2718
2728
  Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
2719
- oo = Openoffice.new(File.join("test","Bibelbund.ods"))
2729
+ oo = Openoffice.new(File.join(TESTDIR,"Bibelbund.ods"))
2720
2730
  oo.default_sheet = oo.sheets.first
2721
2731
  #-----------------------------------------------------------------
2722
2732
  zeilen = oo.find(:all, :conditions => {
@@ -2809,7 +2819,7 @@ class TestRoo < Test::Unit::TestCase
2809
2819
  if EXCEL
2810
2820
  assert_nothing_raised(Timeout::Error) {
2811
2821
  Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
2812
- oo = Excel.new(File.join("test","Bibelbund.xls"))
2822
+ oo = Excel.new(File.join(TESTDIR,"Bibelbund.xls"))
2813
2823
  oo.default_sheet = oo.sheets.first
2814
2824
  #-----------------------------------------------------------------
2815
2825
  zeilen = oo.find(:all, :conditions => {
@@ -2870,7 +2880,7 @@ class TestRoo < Test::Unit::TestCase
2870
2880
 
2871
2881
  #TODO: temporaerer Test
2872
2882
  def test_seiten_als_date
2873
- oo = Excelx.new(File.join("test","Bibelbund.xlsx"))
2883
+ oo = Excelx.new(File.join(TESTDIR,"Bibelbund.xlsx"))
2874
2884
  oo.default_sheet = oo.sheets.first
2875
2885
  assert_equal 'Bericht aus dem Sekretariat', oo.cell(13,1)
2876
2886
  assert_equal '1981-4', oo.cell(13,'D')
@@ -2884,7 +2894,7 @@ class TestRoo < Test::Unit::TestCase
2884
2894
  if EXCELX
2885
2895
  assert_nothing_raised(Timeout::Error) {
2886
2896
  Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
2887
- oo = Excelx.new(File.join("test","Bibelbund.xlsx"))
2897
+ oo = Excelx.new(File.join(TESTDIR,"Bibelbund.xlsx"))
2888
2898
  oo.default_sheet = oo.sheets.first
2889
2899
  #-----------------------------------------------------------------
2890
2900
  zeilen = oo.find(:all, :conditions => {
@@ -3042,7 +3052,7 @@ class TestRoo < Test::Unit::TestCase
3042
3052
  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)]
3043
3053
  if OPENOFFICE
3044
3054
  Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
3045
- oo = Openoffice.new(File.join('test','numbers1.ods'))
3055
+ oo = Openoffice.new(File.join(TESTDIR,'numbers1.ods'))
3046
3056
  oo.default_sheet = oo.sheets.first
3047
3057
  assert_equal expected, oo.column(1)
3048
3058
  assert_equal expected, oo.column('a')
@@ -3055,7 +3065,7 @@ class TestRoo < Test::Unit::TestCase
3055
3065
  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)]
3056
3066
  if EXCEL
3057
3067
  Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
3058
- oo = Excel.new(File.join('test','numbers1.xls'))
3068
+ oo = Excel.new(File.join(TESTDIR,'numbers1.xls'))
3059
3069
  oo.default_sheet = oo.sheets.first
3060
3070
  assert_equal expected, oo.column(1)
3061
3071
  assert_equal expected, oo.column('a')
@@ -3067,7 +3077,7 @@ class TestRoo < Test::Unit::TestCase
3067
3077
  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)]
3068
3078
  if EXCELX
3069
3079
  Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
3070
- oo = Excelx.new(File.join('test','numbers1.xlsx'))
3080
+ oo = Excelx.new(File.join(TESTDIR,'numbers1.xlsx'))
3071
3081
  oo.default_sheet = oo.sheets.first
3072
3082
  assert_equal expected, oo.column(1)
3073
3083
  assert_equal expected, oo.column('a')
@@ -3092,7 +3102,7 @@ class TestRoo < Test::Unit::TestCase
3092
3102
  if OPENOFFICE
3093
3103
  assert_nothing_raised(Timeout::Error) {
3094
3104
  Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
3095
- oo = Openoffice.new(File.join('test','Bibelbund.ods'))
3105
+ oo = Openoffice.new(File.join(TESTDIR,'Bibelbund.ods'))
3096
3106
  oo.default_sheet = oo.sheets.first
3097
3107
  assert_equal 3735, oo.column('a').size
3098
3108
  #assert_equal 499, oo.column('a').size
@@ -3107,7 +3117,7 @@ class TestRoo < Test::Unit::TestCase
3107
3117
  if EXCEL
3108
3118
  assert_nothing_raised(Timeout::Error) {
3109
3119
  Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
3110
- oo = Excel.new(File.join('test','Bibelbund.xls'))
3120
+ oo = Excel.new(File.join(TESTDIR,'Bibelbund.xls'))
3111
3121
  oo.default_sheet = oo.sheets.first
3112
3122
  assert_equal 3735, oo.column('a').size
3113
3123
  #assert_equal 499, oo.column('a').size
@@ -3122,7 +3132,7 @@ class TestRoo < Test::Unit::TestCase
3122
3132
  if EXCELX
3123
3133
  assert_nothing_raised(Timeout::Error) {
3124
3134
  Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
3125
- oo = Excelx.new(File.join('test','Bibelbund.xlsx'))
3135
+ oo = Excelx.new(File.join(TESTDIR,'Bibelbund.xlsx'))
3126
3136
  oo.default_sheet = oo.sheets.first
3127
3137
  assert_equal 3735, oo.column('a').size
3128
3138
  #assert_equal 499, oo.column('a').size
@@ -3150,7 +3160,7 @@ class TestRoo < Test::Unit::TestCase
3150
3160
  end
3151
3161
 
3152
3162
  def test_simple_spreadsheet_find_by_condition_openoffice
3153
- oo = Openoffice.new(File.join("test","simple_spreadsheet.ods"))
3163
+ oo = Openoffice.new(File.join(TESTDIR,"simple_spreadsheet.ods"))
3154
3164
  oo.default_sheet = oo.sheets.first
3155
3165
  oo.header_line = 3
3156
3166
  erg = oo.find(:all, :conditions => {'Comment' => 'Task 1'})
@@ -3165,7 +3175,7 @@ class TestRoo < Test::Unit::TestCase
3165
3175
  def test_simple_spreadsheet_find_by_condition_excel
3166
3176
  if EXCEL
3167
3177
  $debug = true
3168
- oo = Excel.new(File.join("test","simple_spreadsheet.xls"))
3178
+ oo = Excel.new(File.join(TESTDIR,"simple_spreadsheet.xls"))
3169
3179
  oo.default_sheet = oo.sheets.first
3170
3180
  oo.header_line = 3
3171
3181
  erg = oo.find(:all, :conditions => {'Comment' => 'Task 1'})
@@ -3183,7 +3193,7 @@ class TestRoo < Test::Unit::TestCase
3183
3193
  def test_simple_spreadsheet_find_by_condition_excelx
3184
3194
  if EXCELX
3185
3195
  # die dezimalen Seiten bekomme ich seltsamerweise als Date
3186
- oo = Excelx.new(File.join("test","simple_spreadsheet.xlsx"))
3196
+ oo = Excelx.new(File.join(TESTDIR,"simple_spreadsheet.xlsx"))
3187
3197
  oo.default_sheet = oo.sheets.first
3188
3198
  oo.header_line = 3
3189
3199
  erg = oo.find(:all, :conditions => {'Comment' => 'Task 1'})
@@ -3219,6 +3229,7 @@ class TestRoo < Test::Unit::TestCase
3219
3229
  oo = Google.new(key_of("simple_spreadsheet"))
3220
3230
  oo.default_sheet = oo.sheets.first
3221
3231
  oo.header_line = 3
3232
+ oo.date_format = '%m/%d/%Y'
3222
3233
  erg = oo.find(:all, :conditions => {'Comment' => 'Task 1'})
3223
3234
  assert_equal Date.new(2007,05,07), erg[1]['Date']
3224
3235
  assert_equal 10.75 , erg[1]['Start time']
@@ -3231,7 +3242,7 @@ class TestRoo < Test::Unit::TestCase
3231
3242
  end
3232
3243
 
3233
3244
  def DONT_test_false_encoding
3234
- ex = Excel.new(File.join('test','false_encoding.xls'))
3245
+ ex = Excel.new(File.join(TESTDIR,'false_encoding.xls'))
3235
3246
  ex.default_sheet = ex.sheets.first
3236
3247
  assert_equal "Sheet1", ex.sheets.first
3237
3248
  ex.first_row.upto(ex.last_row) do |row|
@@ -3250,7 +3261,7 @@ class TestRoo < Test::Unit::TestCase
3250
3261
  def test_bug_false_borders_with_formulas
3251
3262
  if EXCEL
3252
3263
  after Date.new(2008,9,15) do
3253
- ex = Excel.new(File.join('test','false_encoding.xls'))
3264
+ ex = Excel.new(File.join(TESTDIR,'false_encoding.xls'))
3254
3265
  ex.default_sheet = ex.sheets.first
3255
3266
  #assert_equal 1, ex.first_row
3256
3267
  =begin
@@ -3270,7 +3281,7 @@ class TestRoo < Test::Unit::TestCase
3270
3281
  end
3271
3282
 
3272
3283
  def test_fe
3273
- ex = Excel.new(File.join('test','false_encoding.xls'))
3284
+ ex = Excel.new(File.join(TESTDIR,'false_encoding.xls'))
3274
3285
  ex.default_sheet = ex.sheets.first
3275
3286
  #DOES NOT WORK IN EXCEL FILES: assert_equal Date.new(2007,11,1), ex.cell('a',1)
3276
3287
  #DOES NOT WORK IN EXCEL FILES: assert_equal true, ex.formula?('a',1)
@@ -3296,7 +3307,7 @@ class TestRoo < Test::Unit::TestCase
3296
3307
 
3297
3308
  def test_excel_does_not_support_formulas
3298
3309
  if EXCEL
3299
- ex = Excel.new(File.join('test','false_encoding.xls'))
3310
+ ex = Excel.new(File.join(TESTDIR,'false_encoding.xls'))
3300
3311
  ex.default_sheet = ex.sheets.first
3301
3312
  assert_raise(RuntimeError) {
3302
3313
  void = ex.formula('a',1)
@@ -3342,19 +3353,19 @@ class TestRoo < Test::Unit::TestCase
3342
3353
  if OPENOFFICE
3343
3354
  ext = ".ods"
3344
3355
  expected = sprintf(expected_templ,ext)
3345
- oo = Openoffice.new(File.join("test","numbers1.ods"))
3356
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
3346
3357
  assert_equal expected, oo.info
3347
3358
  end
3348
3359
  if EXCEL
3349
3360
  ext = ".xls"
3350
3361
  expected = sprintf(expected_templ,ext)
3351
- oo = Excel.new(File.join("test","numbers1.xls"))
3362
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
3352
3363
  assert_equal expected, oo.info
3353
3364
  end
3354
3365
  if EXCELX
3355
3366
  ext = ".xlsx"
3356
3367
  expected = sprintf(expected_templ,ext)
3357
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
3368
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
3358
3369
  assert_equal expected, oo.info
3359
3370
  end
3360
3371
  if GOOGLE
@@ -3368,7 +3379,7 @@ class TestRoo < Test::Unit::TestCase
3368
3379
 
3369
3380
  def test_bug_excel_numbers1_sheet5_last_row
3370
3381
  if EXCEL
3371
- oo = Excel.new(File.join("test","numbers1.xls"))
3382
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
3372
3383
  oo.default_sheet = "Tabelle1"
3373
3384
  assert_equal 1, oo.first_row
3374
3385
  assert_equal 18, oo.last_row
@@ -3414,12 +3425,10 @@ class TestRoo < Test::Unit::TestCase
3414
3425
  }
3415
3426
  end
3416
3427
  if GOOGLE
3417
- after Date.new(2009,1,15) do
3418
- assert_raise(IOError) {
3419
- # oo = Google.new(key_of('testnichtvorhanden'+'Bibelbund.ods'))
3420
- oo = Google.new('testnichtvorhanden')
3421
- }
3422
- end
3428
+ # assert_raise(Net::HTTPServerException) {
3429
+ # oo = Google.new(key_of('testnichtvorhanden'+'Bibelbund.ods'))
3430
+ # oo = Google.new('testnichtvorhanden')
3431
+ # }
3423
3432
  end
3424
3433
  end
3425
3434
 
@@ -3438,11 +3447,12 @@ class TestRoo < Test::Unit::TestCase
3438
3447
  def test_write_google
3439
3448
  # write.me: http://spreadsheets.google.com/ccc?key=ptu6bbahNZpY0N0RrxQbWdw&hl=en_GB
3440
3449
  if GOOGLE
3441
- oo = Google.new('ptu6bbahNZpY0N0RrxQbWdw')
3450
+ oo = Google.new(key_of('write.me'))
3442
3451
  oo.default_sheet = oo.sheets.first
3443
3452
  oo.set_value(1,1,"hello from the tests")
3444
- #oo.set_value(1,1,"sin(1)")
3445
3453
  assert_equal "hello from the tests", oo.cell(1,1)
3454
+ oo.set_value(1,1, 1.0)
3455
+ assert_equal 1.0, oo.cell(1,1)
3446
3456
  end
3447
3457
  end
3448
3458
 
@@ -3451,7 +3461,7 @@ class TestRoo < Test::Unit::TestCase
3451
3461
  if GOOGLE
3452
3462
  content1 = 'AAA'
3453
3463
  content2 = 'BBB'
3454
- oo = Google.new('ptu6bbahNZpY0N0RrxQbWdw')
3464
+ oo = Google.new(key_of('write.me'))
3455
3465
  oo.default_sheet = oo.sheets.first
3456
3466
  oo.set_value(1,1,content1)
3457
3467
  oo.default_sheet = oo.sheets[1]
@@ -3467,7 +3477,7 @@ class TestRoo < Test::Unit::TestCase
3467
3477
  if GOOGLE
3468
3478
  random_row = rand(10)+1
3469
3479
  random_column = rand(10)+1
3470
- oo = Google.new('ptu6bbahNZpY0N0RrxQbWdw')
3480
+ oo = Google.new(key_of('write.me'))
3471
3481
  oo.default_sheet = oo.sheets.first
3472
3482
  content1 = 'ABC'
3473
3483
  content2 = 'DEF'
@@ -3489,7 +3499,7 @@ class TestRoo < Test::Unit::TestCase
3489
3499
  end
3490
3500
 
3491
3501
  def test_bug_bbu_openoffice
3492
- oo = Openoffice.new(File.join('test','bbu.ods'))
3502
+ oo = Openoffice.new(File.join(TESTDIR,'bbu.ods'))
3493
3503
  assert_nothing_raised() {
3494
3504
  assert_equal "File: bbu.ods
3495
3505
  Number of sheets: 3
@@ -3514,7 +3524,7 @@ Sheet 3:
3514
3524
 
3515
3525
  def test_bug_bbu_excel
3516
3526
  if EXCEL
3517
- oo = Excel.new(File.join('test','bbu.xls'))
3527
+ oo = Excel.new(File.join(TESTDIR,'bbu.xls'))
3518
3528
  assert_nothing_raised() {
3519
3529
  assert_equal "File: bbu.xls
3520
3530
  Number of sheets: 3
@@ -3540,7 +3550,7 @@ Sheet 3:
3540
3550
 
3541
3551
  def test_bug_bbu_excelx
3542
3552
  if EXCELX
3543
- oo = Excelx.new(File.join('test','bbu.xlsx'))
3553
+ oo = Excelx.new(File.join(TESTDIR,'bbu.xlsx'))
3544
3554
  assert_nothing_raised() {
3545
3555
  assert_equal "File: bbu.xlsx
3546
3556
  Number of sheets: 3
@@ -3593,7 +3603,7 @@ Sheet 3:
3593
3603
 
3594
3604
  def test_bug_time_nil_openoffice
3595
3605
  if OPENOFFICE
3596
- oo = Openoffice.new(File.join("test","time-test.ods"))
3606
+ oo = Openoffice.new(File.join(TESTDIR,"time-test.ods"))
3597
3607
  oo.default_sheet = oo.sheets.first
3598
3608
  assert_equal 12*3600+13*60+14, oo.cell('B',1) # 12:13:14 (secs since midnight)
3599
3609
  assert_equal :time, oo.celltype('B',1)
@@ -3607,7 +3617,7 @@ Sheet 3:
3607
3617
 
3608
3618
  def test_bug_time_nil_excel
3609
3619
  if EXCEL
3610
- oo = Excel.new(File.join("test","time-test.xls"))
3620
+ oo = Excel.new(File.join(TESTDIR,"time-test.xls"))
3611
3621
  oo.default_sheet = oo.sheets.first
3612
3622
  assert_equal 12*3600+13*60+14, oo.cell('B',1) # 12:13:14 (secs since midnight)
3613
3623
  assert_equal :time, oo.celltype('B',1)
@@ -3621,7 +3631,7 @@ Sheet 3:
3621
3631
 
3622
3632
  def test_bug_time_nil_excelx
3623
3633
  if EXCELX
3624
- oo = Excelx.new(File.join("test","time-test.xlsx"))
3634
+ oo = Excelx.new(File.join(TESTDIR,"time-test.xlsx"))
3625
3635
  oo.default_sheet = oo.sheets.first
3626
3636
  assert_equal [:numeric_or_formula, "hh:mm:ss"],oo.excelx_type('b',1)
3627
3637
  assert_in_delta 0.50918981481481485, oo.excelx_value('b', 1), 0.000001
@@ -3653,7 +3663,7 @@ Sheet 3:
3653
3663
  def test_date_time_to_csv_openoffice
3654
3664
  if OPENOFFICE
3655
3665
  File.delete_if_exist("/tmp/time-test.csv")
3656
- oo = Openoffice.new(File.join("test","time-test.ods"))
3666
+ oo = Openoffice.new(File.join(TESTDIR,"time-test.ods"))
3657
3667
  oo.default_sheet = oo.sheets.first
3658
3668
  assert oo.to_csv("/tmp/time-test.csv")
3659
3669
  assert File.exists?("/tmp/time-test.csv")
@@ -3666,7 +3676,7 @@ Sheet 3:
3666
3676
  #ueberfluessige leere Zeilen werden am Ende noch angehaengt
3667
3677
  # last_row fehlerhaft?
3668
3678
  File.delete_if_exist("/tmp/time-test.csv")
3669
- oo = Excel.new(File.join("test","time-test.xls"))
3679
+ oo = Excel.new(File.join(TESTDIR,"time-test.xls"))
3670
3680
  oo.default_sheet = oo.sheets.first
3671
3681
  assert oo.to_csv("/tmp/time-test.csv")
3672
3682
  assert File.exists?("/tmp/time-test.csv")
@@ -3679,7 +3689,7 @@ Sheet 3:
3679
3689
  #ueberfluessige leere Zeilen werden am Ende noch angehaengt
3680
3690
  # last_row fehlerhaft?
3681
3691
  File.delete_if_exist("/tmp/time-test.csv")
3682
- oo = Excelx.new(File.join("test","time-test.xlsx"))
3692
+ oo = Excelx.new(File.join(TESTDIR,"time-test.xlsx"))
3683
3693
  oo.default_sheet = oo.sheets.first
3684
3694
  assert oo.to_csv("/tmp/time-test.csv")
3685
3695
  assert File.exists?("/tmp/time-test.csv")
@@ -3694,7 +3704,7 @@ Sheet 3:
3694
3704
  oo.default_sheet = oo.sheets.first
3695
3705
  assert oo.to_csv("/tmp/time-test.csv")
3696
3706
  assert File.exists?("/tmp/time-test.csv")
3697
- assert_equal "", `diff test/time-test.csv /tmp/time-test.csv`
3707
+ assert_equal "", `diff #{File.join(TESTDIR,"time-test.csv")} /tmp/time-test.csv`
3698
3708
  end # GOOGLE
3699
3709
  end
3700
3710
 
@@ -3702,7 +3712,7 @@ Sheet 3:
3702
3712
  if OPENOFFICE
3703
3713
  expected =
3704
3714
  "--- \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"
3705
- oo = Openoffice.new(File.join("test","time-test.ods"))
3715
+ oo = Openoffice.new(File.join(TESTDIR,"time-test.ods"))
3706
3716
  oo.default_sheet = oo.sheets.first
3707
3717
  assert_equal expected, oo.to_yaml
3708
3718
  end
@@ -3712,7 +3722,7 @@ Sheet 3:
3712
3722
  if EXCEL
3713
3723
  expected =
3714
3724
  "--- \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"
3715
- oo = Excel.new(File.join("test","time-test.xls"))
3725
+ oo = Excel.new(File.join(TESTDIR,"time-test.xls"))
3716
3726
  oo.default_sheet = oo.sheets.first
3717
3727
  assert_equal expected, oo.to_yaml
3718
3728
  end
@@ -3722,7 +3732,7 @@ Sheet 3:
3722
3732
  if EXCELX
3723
3733
  expected =
3724
3734
  "--- \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"
3725
- oo = Excelx.new(File.join("test","time-test.xlsx"))
3735
+ oo = Excelx.new(File.join(TESTDIR,"time-test.xlsx"))
3726
3736
  oo.default_sheet = oo.sheets.first
3727
3737
  assert_equal expected, oo.to_yaml
3728
3738
  end
@@ -3741,9 +3751,9 @@ Sheet 3:
3741
3751
  def test_no_remaining_tmp_files_openoffice
3742
3752
  if OPENOFFICE
3743
3753
  assert_raise(Zip::ZipError) { #TODO: besseres Fehlerkriterium bei
3744
- # oo = Openoffice.new(File.join("test","no_spreadsheet_file.txt"))
3754
+ # oo = Openoffice.new(File.join(TESTDIR,"no_spreadsheet_file.txt"))
3745
3755
  # es soll absichtlich ein Abbruch provoziert werden, deshalb :ignore
3746
- oo = Openoffice.new(File.join("test","no_spreadsheet_file.txt"),
3756
+ oo = Openoffice.new(File.join(TESTDIR,"no_spreadsheet_file.txt"),
3747
3757
  false,
3748
3758
  :ignore)
3749
3759
  }
@@ -3754,10 +3764,10 @@ Sheet 3:
3754
3764
 
3755
3765
  def test_no_remaining_tmp_files_excel
3756
3766
  if EXCEL
3757
- assert_raise(OLE::UnknownFormatError) {
3758
- # oo = Excel.new(File.join("test","no_spreadsheet_file.txt"))
3767
+ assert_raise(Ole::Storage::FormatError) {
3768
+ # oo = Excel.new(File.join(TESTDIR,"no_spreadsheet_file.txt"))
3759
3769
  # es soll absichtlich ein Abbruch provoziert werden, deshalb :ignore
3760
- oo = Excel.new(File.join("test","no_spreadsheet_file.txt"),
3770
+ oo = Excel.new(File.join(TESTDIR,"no_spreadsheet_file.txt"),
3761
3771
  false,
3762
3772
  :ignore)
3763
3773
  }
@@ -3770,9 +3780,9 @@ Sheet 3:
3770
3780
  if EXCELX
3771
3781
  assert_raise(Zip::ZipError) { #TODO: besseres Fehlerkriterium bei
3772
3782
 
3773
- # oo = Excelx.new(File.join("test","no_spreadsheet_file.txt"))
3783
+ # oo = Excelx.new(File.join(TESTDIR,"no_spreadsheet_file.txt"))
3774
3784
  # es soll absichtlich ein Abbruch provoziert werden, deshalb :ignore
3775
- oo = Excelx.new(File.join("test","no_spreadsheet_file.txt"),
3785
+ oo = Excelx.new(File.join(TESTDIR,"no_spreadsheet_file.txt"),
3776
3786
  false,
3777
3787
  :ignore)
3778
3788
 
@@ -3814,7 +3824,7 @@ Sheet 3:
3814
3824
  def do_test_xml(oo)
3815
3825
  assert_nothing_raised {oo.to_xml}
3816
3826
  sheetname = oo.sheets.first
3817
- doc = REXML::Document.new(oo.to_xml)
3827
+ doc = XML::Parser.string(oo.to_xml).parse
3818
3828
  doc.root.each_element {|xml_sheet|
3819
3829
  all_cells = init_all_cells(oo, sheetname)
3820
3830
  x = 0
@@ -3828,7 +3838,7 @@ Sheet 3:
3828
3838
  result = [
3829
3839
  cell.attributes['row'],
3830
3840
  cell.attributes['column'],
3831
- cell.text,
3841
+ cell.content,
3832
3842
  cell.attributes['type'],
3833
3843
  ]
3834
3844
  assert_equal expected, result
@@ -3840,44 +3850,44 @@ Sheet 3:
3840
3850
 
3841
3851
  def test_to_xml_openoffice
3842
3852
  if OPENOFFICE
3843
- oo = Openoffice.new(File.join('test','numbers1.ods'))
3853
+ oo = Openoffice.new(File.join(TESTDIR,'numbers1.ods'))
3844
3854
  do_test_xml(oo)
3845
3855
  end
3846
3856
  end
3847
3857
 
3848
3858
  def test_to_xml_excel
3849
3859
  if EXCEL
3850
- oo = Excel.new(File.join('test','numbers1.xls'))
3860
+ oo = Excel.new(File.join(TESTDIR,'numbers1.xls'))
3851
3861
  do_test_xml(oo)
3852
3862
  end
3853
3863
  end
3854
3864
 
3855
3865
  def test_to_xml_excelx
3856
3866
  if EXCELX
3857
- oo = Excelx.new(File.join('test','numbers1.xlsx'))
3867
+ oo = Excelx.new(File.join(TESTDIR,'numbers1.xlsx'))
3858
3868
  do_test_xml(oo)
3859
3869
  end
3860
3870
  end
3861
3871
 
3862
3872
  def test_to_xml_google
3863
3873
  if GOOGLE
3864
- oo = Google.new(key_of(File.join('test','numbers1.xlsx')))
3874
+ oo = Google.new(key_of(File.join(TESTDIR,'numbers1.xlsx')))
3865
3875
  do_test_xml(oo)
3866
3876
  end
3867
3877
  end
3868
3878
 
3869
- def test_invalid_iconv_from_ms
3879
+ def SKIP_test_invalid_iconv_from_ms
3870
3880
  #TODO: does only run within a darwin-environment
3871
3881
  if RUBY_PLATFORM.downcase =~ /darwin/
3872
3882
  assert_nothing_raised() {
3873
- oo = Excel.new(File.join("test","ms.xls"))
3883
+ oo = Excel.new(File.join(TESTDIR,"ms.xls"))
3874
3884
  }
3875
3885
  end
3876
3886
  end
3877
3887
 
3878
3888
  def test_bug_row_column_fixnum_float
3879
3889
  if EXCEL
3880
- ex = Excel.new(File.join('test','bug-row-column-fixnum-float.xls'))
3890
+ ex = Excel.new(File.join(TESTDIR,'bug-row-column-fixnum-float.xls'))
3881
3891
  ex.default_sheet = ex.sheets.first
3882
3892
  assert_equal 42.5, ex.cell('b',2)
3883
3893
  assert_equal 43 , ex.cell('c',2)
@@ -3898,7 +3908,7 @@ Sheet 3:
3898
3908
  'Fish','Love','Feelgood ES','Feelgood','GTwin','Troop',
3899
3909
  'Lux','Stigma','Feather','Stria','Alpha','Feelgood ICS']
3900
3910
  result = []
3901
- @e = Excel.new(File.join('test',"problem.xls"))
3911
+ @e = Excel.new(File.join(TESTDIR,"problem.xls"))
3902
3912
  @e.sheets[2..@e.sheets.length].each do |s|
3903
3913
  #(13..13).each do |s|
3904
3914
  @e.default_sheet = s
@@ -3917,7 +3927,7 @@ Sheet 3:
3917
3927
  after Date.new(2009,1,10) do
3918
3928
  local_only do
3919
3929
  #-- this is OK
3920
- @workbook = Spreadsheet::ParseExcel.parse(File.join('test',"problem.xls"))
3930
+ @workbook = Spreadsheet::ParseExcel.parse(File.join(TESTDIR,"problem.xls"))
3921
3931
  worksheet = @workbook.worksheet(11)
3922
3932
  skip = 0
3923
3933
  line = 1
@@ -3935,7 +3945,7 @@ Sheet 3:
3935
3945
  line += 1
3936
3946
  }
3937
3947
  #-- worksheet 12 does not work
3938
- @workbook = Spreadsheet::ParseExcel.parse(File.join('test',"problem.xls"))
3948
+ @workbook = Spreadsheet::ParseExcel.parse(File.join(TESTDIR,"problem.xls"))
3939
3949
  worksheet = @workbook.worksheet(12)
3940
3950
  skip = 0
3941
3951
  line = 1
@@ -3966,7 +3976,7 @@ Sheet 3:
3966
3976
  'Fish','Love','Feelgood ES','Feelgood','GTwin','Troop',
3967
3977
  'Lux','Stigma','Feather','Stria','Alpha','Feelgood ICS']
3968
3978
  result = []
3969
- @e = Excelx.new(File.join('test',"problem.xlsx"))
3979
+ @e = Excelx.new(File.join(TESTDIR,"problem.xlsx"))
3970
3980
  @e.sheets[2..@e.sheets.length].each do |s|
3971
3981
  @e.default_sheet = s
3972
3982
  # assert_equal "A.",@e.cell('a',13)
@@ -3979,7 +3989,7 @@ Sheet 3:
3979
3989
  end
3980
3990
  assert_equal expected, result
3981
3991
 
3982
- @e = Excelx.new(File.join('test',"problem.xlsx"))
3992
+ @e = Excelx.new(File.join(TESTDIR,"problem.xlsx"))
3983
3993
  #@e.sheets[2..@e.sheets.length].each do |s|
3984
3994
  (13..13).each do |s|
3985
3995
  @e.default_sheet = s
@@ -3996,8 +4006,8 @@ Sheet 3:
3996
4006
  after Date.new(2008,12,30) do
3997
4007
  # parseexcel bug
3998
4008
  local_only do
3999
- s1 = Excel.new(File.join("test","problem.xls"))
4000
- s2 = Excelx.new(File.join("test","problem.xlsx"))
4009
+ s1 = Excel.new(File.join(TESTDIR,"problem.xls"))
4010
+ s2 = Excelx.new(File.join(TESTDIR,"problem.xlsx"))
4001
4011
  s1.sheets.each {|sh| #TODO:
4002
4012
  s1.default_sheet = sh
4003
4013
  s2.default_sheet = sh
@@ -4021,8 +4031,8 @@ Sheet 3:
4021
4031
  # wieder eingelesene CSV-Datei aus obigem Test
4022
4032
  # muss identisch mit problem.xls sein
4023
4033
  # Importieren aus csv-Datei muss manuell gemacht werden
4024
- ex = Excel.new(File.join("test","problem.xls"))
4025
- cs = Excel.new(File.join("test","problemx_csv_imported.xls"))
4034
+ ex = Excel.new(File.join(TESTDIR,"problem.xls"))
4035
+ cs = Excel.new(File.join(TESTDIR,"problemx_csv_imported.xls"))
4026
4036
  # nur das erste sheet betrachten
4027
4037
  ex.default_sheet = ex.sheets.first
4028
4038
  cs.default_sheet = cs.sheets.first
@@ -4055,36 +4065,36 @@ Sheet 3:
4055
4065
 
4056
4066
  def test_file_warning_default
4057
4067
  if OPENOFFICE
4058
- assert_raises(TypeError) { oo = Openoffice.new(File.join("test","numbers1.xls")) }
4059
- assert_raises(TypeError) { oo = Openoffice.new(File.join("test","numbers1.xlsx")) }
4068
+ assert_raises(TypeError) { oo = Openoffice.new(File.join(TESTDIR,"numbers1.xls")) }
4069
+ assert_raises(TypeError) { oo = Openoffice.new(File.join(TESTDIR,"numbers1.xlsx")) }
4060
4070
  assert_equal [], Dir.glob("oo_*")
4061
4071
  end
4062
4072
  if EXCEL
4063
- assert_raises(TypeError) { oo = Excel.new(File.join("test","numbers1.ods")) }
4064
- assert_raises(TypeError) { oo = Excel.new(File.join("test","numbers1.xlsx")) }
4073
+ assert_raises(TypeError) { oo = Excel.new(File.join(TESTDIR,"numbers1.ods")) }
4074
+ assert_raises(TypeError) { oo = Excel.new(File.join(TESTDIR,"numbers1.xlsx")) }
4065
4075
  assert_equal [], Dir.glob("oo_*")
4066
4076
  end
4067
4077
  if EXCELX
4068
- assert_raises(TypeError) { oo = Excelx.new(File.join("test","numbers1.ods")) }
4069
- assert_raises(TypeError) { oo = Excelx.new(File.join("test","numbers1.xls")) }
4078
+ assert_raises(TypeError) { oo = Excelx.new(File.join(TESTDIR,"numbers1.ods")) }
4079
+ assert_raises(TypeError) { oo = Excelx.new(File.join(TESTDIR,"numbers1.xls")) }
4070
4080
  assert_equal [], Dir.glob("oo_*")
4071
4081
  end
4072
4082
  end
4073
4083
 
4074
4084
  def test_file_warning_error
4075
4085
  if OPENOFFICE
4076
- assert_raises(TypeError) { oo = Openoffice.new(File.join("test","numbers1.xls"),false,:error) }
4077
- assert_raises(TypeError) { oo = Openoffice.new(File.join("test","numbers1.xlsx"),false,:error) }
4086
+ assert_raises(TypeError) { oo = Openoffice.new(File.join(TESTDIR,"numbers1.xls"),false,:error) }
4087
+ assert_raises(TypeError) { oo = Openoffice.new(File.join(TESTDIR,"numbers1.xlsx"),false,:error) }
4078
4088
  assert_equal [], Dir.glob("oo_*")
4079
4089
  end
4080
4090
  if EXCEL
4081
- assert_raises(TypeError) { oo = Excel.new(File.join("test","numbers1.ods"),false,:error) }
4082
- assert_raises(TypeError) { oo = Excel.new(File.join("test","numbers1.xlsx"),false,:error) }
4091
+ assert_raises(TypeError) { oo = Excel.new(File.join(TESTDIR,"numbers1.ods"),false,:error) }
4092
+ assert_raises(TypeError) { oo = Excel.new(File.join(TESTDIR,"numbers1.xlsx"),false,:error) }
4083
4093
  assert_equal [], Dir.glob("oo_*")
4084
4094
  end
4085
4095
  if EXCELX
4086
- assert_raises(TypeError) { oo = Excelx.new(File.join("test","numbers1.ods"),false,:error) }
4087
- assert_raises(TypeError) { oo = Excelx.new(File.join("test","numbers1.xls"),false,:error) }
4096
+ assert_raises(TypeError) { oo = Excelx.new(File.join(TESTDIR,"numbers1.ods"),false,:error) }
4097
+ assert_raises(TypeError) { oo = Excelx.new(File.join(TESTDIR,"numbers1.xls"),false,:error) }
4088
4098
  assert_equal [], Dir.glob("oo_*")
4089
4099
  end
4090
4100
  end
@@ -4093,35 +4103,35 @@ Sheet 3:
4093
4103
  if OPENOFFICE
4094
4104
  assert_nothing_raised(TypeError) {
4095
4105
  assert_raises(Zip::ZipError) {
4096
- oo = Openoffice.new(File.join("test","numbers1.xls"),false, :warning)
4106
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.xls"),false, :warning)
4097
4107
  }
4098
4108
  }
4099
4109
  assert_nothing_raised(TypeError) {
4100
4110
  assert_raises(Errno::ENOENT) {
4101
- oo = Openoffice.new(File.join("test","numbers1.xlsx"),false, :warning)
4111
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.xlsx"),false, :warning)
4102
4112
  }
4103
4113
  }
4104
4114
  assert_equal [], Dir.glob("oo_*")
4105
4115
  end
4106
4116
  if EXCEL
4107
4117
  assert_nothing_raised(TypeError) {
4108
- assert_raises(OLE::UnknownFormatError) {
4109
- oo = Excel.new(File.join("test","numbers1.ods"),false, :warning) }
4118
+ assert_raises(Ole::Storage::FormatError) {
4119
+ oo = Excel.new(File.join(TESTDIR,"numbers1.ods"),false, :warning) }
4110
4120
  }
4111
4121
  assert_nothing_raised(TypeError) {
4112
- assert_raises(OLE::UnknownFormatError) {
4113
- oo = Excel.new(File.join("test","numbers1.xlsx"),false, :warning) }
4122
+ assert_raises(Ole::Storage::FormatError) {
4123
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xlsx"),false, :warning) }
4114
4124
  }
4115
4125
  assert_equal [], Dir.glob("oo_*")
4116
4126
  end
4117
4127
  if EXCELX
4118
4128
  assert_nothing_raised(TypeError) {
4119
4129
  assert_raises(Errno::ENOENT) {
4120
- oo = Excelx.new(File.join("test","numbers1.ods"),false, :warning) }
4130
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.ods"),false, :warning) }
4121
4131
  }
4122
4132
  assert_nothing_raised(TypeError) {
4123
4133
  assert_raises(Zip::ZipError) {
4124
- oo = Excelx.new(File.join("test","numbers1.xls"),false, :warning) }
4134
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xls"),false, :warning) }
4125
4135
  }
4126
4136
  assert_equal [], Dir.glob("oo_*")
4127
4137
  end
@@ -4131,39 +4141,39 @@ Sheet 3:
4131
4141
  if OPENOFFICE
4132
4142
  assert_nothing_raised(TypeError) {
4133
4143
  assert_raises(Zip::ZipError) {
4134
- oo = Openoffice.new(File.join("test","numbers1.xls"),false, :ignore) }
4144
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.xls"),false, :ignore) }
4135
4145
  }
4136
4146
  assert_nothing_raised(TypeError) {
4137
4147
  assert_raises(Errno::ENOENT) {
4138
- oo = Openoffice.new(File.join("test","numbers1.xlsx"),false, :ignore) }
4148
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.xlsx"),false, :ignore) }
4139
4149
  }
4140
4150
  assert_equal [], Dir.glob("oo_*")
4141
4151
  end
4142
4152
  if EXCEL
4143
4153
  assert_nothing_raised(TypeError) {
4144
- assert_raises(OLE::UnknownFormatError) {
4145
- oo = Excel.new(File.join("test","numbers1.ods"),false, :ignore) }
4154
+ assert_raises(Ole::Storage::FormatError) {
4155
+ oo = Excel.new(File.join(TESTDIR,"numbers1.ods"),false, :ignore) }
4146
4156
  }
4147
4157
  assert_nothing_raised(TypeError) {
4148
- assert_raises(OLE::UnknownFormatError) {oo = Excel.new(File.join("test","numbers1.xlsx"),false, :ignore) }}
4158
+ assert_raises(Ole::Storage::FormatError) {oo = Excel.new(File.join(TESTDIR,"numbers1.xlsx"),false, :ignore) }}
4149
4159
  assert_equal [], Dir.glob("oo_*")
4150
4160
  end
4151
4161
  if EXCELX
4152
4162
  assert_nothing_raised(TypeError) {
4153
4163
  assert_raises(Errno::ENOENT) {
4154
- oo = Excelx.new(File.join("test","numbers1.ods"),false, :ignore)
4164
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.ods"),false, :ignore)
4155
4165
  }
4156
4166
  }
4157
4167
  assert_nothing_raised(TypeError) {
4158
4168
  assert_raises(Zip::ZipError) {
4159
- oo = Excelx.new(File.join("test","numbers1.xls"),false, :ignore)
4169
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xls"),false, :ignore)
4160
4170
  }
4161
4171
  }
4162
4172
  assert_equal [], Dir.glob("oo_*")
4163
4173
  end
4164
4174
  end
4165
4175
 
4166
- def test_open_from_uri
4176
+ def SKIP_test_open_from_uri
4167
4177
  if ONLINE
4168
4178
  if OPENOFFICE
4169
4179
  assert_raises(RuntimeError) {
@@ -4185,7 +4195,7 @@ Sheet 3:
4185
4195
 
4186
4196
  def test_bug_last_row_excel
4187
4197
  if EXCEL
4188
- oo = Excel.new(File.join("test","time-test.xls"))
4198
+ oo = Excel.new(File.join(TESTDIR,"time-test.xls"))
4189
4199
  oo.default_sheet = oo.sheets.first
4190
4200
  assert_equal 2, oo.last_row
4191
4201
  end
@@ -4193,7 +4203,7 @@ Sheet 3:
4193
4203
 
4194
4204
  def test_bug_to_xml_with_empty_sheets_openoffice
4195
4205
  if OPENOFFICE
4196
- oo = Openoffice.new(File.join("test","emptysheets.ods"))
4206
+ oo = Openoffice.new(File.join(TESTDIR,"emptysheets.ods"))
4197
4207
  oo.sheets.each { |sheet|
4198
4208
  oo.default_sheet = sheet
4199
4209
  assert_equal nil, oo.first_row, "first_row not nil in sheet #{sheet}"
@@ -4213,7 +4223,7 @@ Sheet 3:
4213
4223
 
4214
4224
  def test_bug_to_xml_with_empty_sheets_excel
4215
4225
  if EXCEL
4216
- oo = Excel.new(File.join("test","emptysheets.xls"))
4226
+ oo = Excel.new(File.join(TESTDIR,"emptysheets.xls"))
4217
4227
  oo.sheets.each { |sheet|
4218
4228
  oo.default_sheet = sheet
4219
4229
  assert_equal nil, oo.first_row, "first_row not nil in sheet #{sheet}"
@@ -4234,7 +4244,7 @@ Sheet 3:
4234
4244
  def test_bug_to_xml_with_empty_sheets_excelx
4235
4245
  # kann ich nicht testen, da ich selbst keine .xlsx Files anlegen kann
4236
4246
  if EXCELX
4237
- # oo = Excelx.new(File.join("test","emptysheets.xlsx"))
4247
+ # oo = Excelx.new(File.join(TESTDIR,"emptysheets.xlsx"))
4238
4248
  # oo.sheets.each { |sheet|
4239
4249
  # oo.default_sheet = sheet
4240
4250
  # assert_equal nil, oo.first_row, "first_row not nil in sheet #{sheet}"
@@ -4257,7 +4267,7 @@ Sheet 3:
4257
4267
  # really a bug? are cells really of type time?
4258
4268
  # No! :float must be the correct type
4259
4269
  if EXCELX
4260
- oo = Excelx.new(File.join("test","simple_spreadsheet.xlsx"))
4270
+ oo = Excelx.new(File.join(TESTDIR,"simple_spreadsheet.xlsx"))
4261
4271
  oo.default_sheet = oo.sheets.first
4262
4272
  # puts oo.cell('B',5).to_s
4263
4273
  # assert_equal :time, oo.celltype('B',5)
@@ -4276,7 +4286,7 @@ Sheet 3:
4276
4286
  def test_to_ascii_openoffice
4277
4287
  if OPENOFFICE
4278
4288
  after Date.new(9999,12,31) do
4279
- oo = Openoffice.new(File.join("test","verysimple_spreadsheet.ods"))
4289
+ oo = Openoffice.new(File.join(TESTDIR,"verysimple_spreadsheet.ods"))
4280
4290
  oo.default_sheet = oo.sheets.first
4281
4291
  expected="
4282
4292
  A | B | C |
@@ -4296,7 +4306,7 @@ Sheet 3:
4296
4306
  def test_simple2_excelx
4297
4307
  if EXCELX
4298
4308
  after Date.new(2008,8,2) do
4299
- oo = Excelx.new(File.join("test","simple_spreadsheet.xlsx"))
4309
+ oo = Excelx.new(File.join(TESTDIR,"simple_spreadsheet.xlsx"))
4300
4310
  oo.default_sheet = oo.sheets.first
4301
4311
  assert_equal [:numeric_or_formula, "yyyy\\-mm\\-dd"], oo.excelx_type('A',4)
4302
4312
  assert_equal [:numeric_or_formula, "#,##0.00"], oo.excelx_type('B',4)
@@ -4333,7 +4343,7 @@ Sheet 3:
4333
4343
  after Date.new(2008,12,15) do
4334
4344
  local_only do
4335
4345
  if EXCEL
4336
- ex = Excel.new(File.join('test','problem.xls'))
4346
+ ex = Excel.new(File.join(TESTDIR,'problem.xls'))
4337
4347
  ex.default_sheet = ex.sheets.first
4338
4348
  assert_equal 2, ex.first_row
4339
4349
  assert_equal 30, ex.last_row
@@ -4341,7 +4351,7 @@ Sheet 3:
4341
4351
  assert_equal 'J', ex.last_column_as_letter
4342
4352
  end
4343
4353
  if EXCELX
4344
- ex = Excelx.new(File.join('test','problem.xlsx'))
4354
+ ex = Excelx.new(File.join(TESTDIR,'problem.xlsx'))
4345
4355
  ex.default_sheet = ex.sheets.first
4346
4356
  assert_equal 2, ex.first_row
4347
4357
  assert_equal 30, ex.last_row
@@ -4372,13 +4382,13 @@ Sheet 3:
4372
4382
  after Date.new(2009,1,6) do
4373
4383
  # warten auf Bugfix in parseexcel
4374
4384
  if EXCEL
4375
- ex = Excel.new(File.join('test','problem.xls'))
4385
+ ex = Excel.new(File.join(TESTDIR,'problem.xls'))
4376
4386
  ex.default_sheet = 'Custom X'
4377
4387
  common_possible_bug_snowboard_cells(ex)
4378
4388
  end
4379
4389
  end
4380
4390
  if EXCELX
4381
- ex = Excelx.new(File.join('test','problem.xlsx'))
4391
+ ex = Excelx.new(File.join(TESTDIR,'problem.xlsx'))
4382
4392
  ex.default_sheet = 'Custom X'
4383
4393
  common_possible_bug_snowboard_cells(ex)
4384
4394
  end
@@ -4595,7 +4605,7 @@ Even stranger is if I save this file as ".XLS" and parse it the cells parse out
4595
4605
  This attached file is the newer format of Microsoft Excel (.xlsx).
4596
4606
 
4597
4607
  =end
4598
- xx = Excelx.new(File.join('test','sample_file_2008-09-13.xlsx'))
4608
+ xx = Excelx.new(File.join(TESTDIR,'sample_file_2008-09-13.xlsx'))
4599
4609
  assert_equal 1, xx.sheets.size
4600
4610
 
4601
4611
  assert_equal 1, xx.first_row
@@ -4629,7 +4639,7 @@ This attached file is the newer format of Microsoft Excel (.xlsx).
4629
4639
  end
4630
4640
 
4631
4641
  def do_datetime_tests(oo)
4632
- val = oo.cell('c',3)
4642
+ val = oo.cell('c',3)
4633
4643
  assert_kind_of DateTime, val
4634
4644
  assert_equal :datetime, oo.celltype('c',3)
4635
4645
  assert_equal DateTime.new(1961,11,21,12,17,18), val
@@ -4658,7 +4668,7 @@ This attached file is the newer format of Microsoft Excel (.xlsx).
4658
4668
 
4659
4669
  def test_datetime_openoffice
4660
4670
  if OPENOFFICE
4661
- oo = Openoffice.new(File.join("test","datetime.ods"))
4671
+ oo = Openoffice.new(File.join(TESTDIR,"datetime.ods"))
4662
4672
  oo.default_sheet = oo.sheets.first
4663
4673
  do_datetime_tests(oo)
4664
4674
  end
@@ -4666,7 +4676,7 @@ This attached file is the newer format of Microsoft Excel (.xlsx).
4666
4676
 
4667
4677
  def test_datetime_excel
4668
4678
  if EXCEL
4669
- oo = Excel.new(File.join("test","datetime.xls"))
4679
+ oo = Excel.new(File.join(TESTDIR,"datetime.xls"))
4670
4680
  oo.default_sheet = oo.sheets.first
4671
4681
  do_datetime_tests(oo)
4672
4682
  end
@@ -4674,7 +4684,7 @@ This attached file is the newer format of Microsoft Excel (.xlsx).
4674
4684
 
4675
4685
  def test_datetime_excelx
4676
4686
  if EXCELX
4677
- oo = Excelx.new(File.join("test","datetime.xlsx"))
4687
+ oo = Excelx.new(File.join(TESTDIR,"datetime.xlsx"))
4678
4688
  oo.default_sheet = oo.sheets.first
4679
4689
  do_datetime_tests(oo)
4680
4690
  end
@@ -4804,11 +4814,11 @@ This attached file is the newer format of Microsoft Excel (.xlsx).
4804
4814
 
4805
4815
  # Eine Spreadsheetdatei wird nicht als Dateiname sondern direkt als Dokument
4806
4816
  # geoeffnettest_problemx_csv_imported
4807
- def test_from_stream_openoffice
4817
+ def SKIP_test_from_stream_openoffice
4808
4818
  after Date.new(2009,1,6) do
4809
4819
  if OPENOFFICE
4810
4820
  filecontent = nil
4811
- File.open(File.join("test","numbers1.ods")) do |f|
4821
+ File.open(File.join(TESTDIR,"numbers1.ods")) do |f|
4812
4822
  filecontent = f.read
4813
4823
  p filecontent.class
4814
4824
  p filecontent.size
@@ -4823,11 +4833,160 @@ This attached file is the newer format of Microsoft Excel (.xlsx).
4823
4833
  end
4824
4834
 
4825
4835
 
4826
- def test_bug_encoding_exported_from_google
4836
+ def SKIP_test_bug_encoding_exported_from_google
4827
4837
  if EXCEL
4828
- xl = Excel.new(File.join("test","numbers1_from_google.xls"))
4838
+ xl = Excel.new(File.join(TESTDIR,"numbers1_from_google.xls"))
4829
4839
  xl.default_sheet = xl.sheets.first
4830
4840
  assert_equal 'test', xl.cell(2,'F')
4831
4841
  end
4832
4842
  end
4843
+
4844
+ def test_cell_openoffice_html_escape
4845
+ if OPENOFFICE
4846
+ oo = Openoffice.new(File.join(TESTDIR,"html-escape.ods"))
4847
+ oo.default_sheet = oo.sheets.first
4848
+ assert_equal "'", oo.cell(1,1)
4849
+ assert_equal "&", oo.cell(2,1)
4850
+ assert_equal ">", oo.cell(3,1)
4851
+ assert_equal "<", oo.cell(4,1)
4852
+ assert_equal "`", oo.cell(5,1)
4853
+ # test_openoffice_zipped catches the &quot;
4854
+ end
4855
+ end
4856
+
4857
+ def test_cell_boolean
4858
+ if EXCEL
4859
+ oo = Excel.new(File.join(TESTDIR,"boolean.xls"))
4860
+ oo.default_sheet = oo.sheets.first
4861
+ assert_equal "true", oo.cell(1,1)
4862
+ assert_equal "false", oo.cell(2,1)
4863
+ end
4864
+ if OPENOFFICE
4865
+ oo = Openoffice.new(File.join(TESTDIR,"boolean.ods"))
4866
+ oo.default_sheet = oo.sheets.first
4867
+ assert_equal "true", oo.cell(1,1)
4868
+ assert_equal "false", oo.cell(2,1)
4869
+ end
4870
+ if EXCELX
4871
+ oo = Excelx.new(File.join(TESTDIR,"boolean.xlsx"))
4872
+ oo.default_sheet = oo.sheets.first
4873
+ assert_equal "TRUE", oo.cell(1,1)
4874
+ assert_equal "FALSE", oo.cell(2,1)
4875
+ end
4876
+ end
4877
+
4878
+ def test_cell_multiline
4879
+ if EXCEL
4880
+ oo = Excel.new(File.join(TESTDIR,"paragraph.xls"))
4881
+ oo.default_sheet = oo.sheets.first
4882
+ assert_equal "This is a test\nof a multiline\nCell", oo.cell(1,1)
4883
+ assert_equal "This is a test\n¶\nof a multiline\n\nCell", oo.cell(1,2)
4884
+ assert_equal "first p\n\nsecond p\n\nlast p", oo.cell(2,1)
4885
+ end
4886
+ if OPENOFFICE
4887
+ oo = Openoffice.new(File.join(TESTDIR,"paragraph.ods"))
4888
+ oo.default_sheet = oo.sheets.first
4889
+ assert_equal "This is a test\nof a multiline\nCell", oo.cell(1,1)
4890
+ assert_equal "This is a test\n¶\nof a multiline\n\nCell", oo.cell(1,2)
4891
+ assert_equal "first p\n\nsecond p\n\nlast p", oo.cell(2,1)
4892
+ end
4893
+ if EXCELX
4894
+ oo = Excelx.new(File.join(TESTDIR,"paragraph.xlsx"))
4895
+ oo.default_sheet = oo.sheets.first
4896
+ assert_equal "This is a test\nof a multiline\nCell", oo.cell(1,1)
4897
+ assert_equal "This is a test\n¶\nof a multiline\n\nCell", oo.cell(1,2)
4898
+ assert_equal "first p\n\nsecond p\n\nlast p", oo.cell(2,1)
4899
+ end
4900
+ end
4901
+
4902
+
4903
+ # for test_cell_styles
4904
+ def verify_cell_fonts(oo)
4905
+ oo.default_sheet = oo.sheets.first
4906
+
4907
+ # bold
4908
+ assert_equal true, oo.font(1,1).bold?
4909
+ assert_equal false, oo.font(1,1).italic?
4910
+ assert_equal false, oo.font(1,1).underline?
4911
+
4912
+ # italic
4913
+ assert_equal false, oo.font(2,1).bold?
4914
+ assert_equal true, oo.font(2,1).italic?
4915
+ assert_equal false, oo.font(2,1).underline?
4916
+
4917
+ # normal
4918
+ assert_equal false, oo.font(3,1).bold?
4919
+ assert_equal false, oo.font(3,1).italic?
4920
+ assert_equal false, oo.font(3,1).underline?
4921
+
4922
+ # underline
4923
+ assert_equal false, oo.font(4,1).bold?
4924
+ assert_equal false, oo.font(4,1).italic?
4925
+ assert_equal true, oo.font(4,1).underline?
4926
+
4927
+ # bold italic
4928
+ assert_equal true, oo.font(5,1).bold?
4929
+ assert_equal true, oo.font(5,1).italic?
4930
+ assert_equal false, oo.font(5,1).underline?
4931
+
4932
+ # bold underline
4933
+ assert_equal true, oo.font(6,1).bold?
4934
+ assert_equal false, oo.font(6,1).italic?
4935
+ assert_equal true, oo.font(6,1).underline?
4936
+
4937
+ # italic underline
4938
+ assert_equal false, oo.font(7,1).bold?
4939
+ assert_equal true, oo.font(7,1).italic?
4940
+ assert_equal true, oo.font(7,1).underline?
4941
+
4942
+ # bolded row
4943
+ assert_equal true, oo.font(8,1).bold?
4944
+ assert_equal false, oo.font(8,1).italic?
4945
+ assert_equal false, oo.font(8,1).underline?
4946
+
4947
+ # bolded col
4948
+ assert_equal true, oo.font(9,2).bold?
4949
+ assert_equal false, oo.font(9,2).italic?
4950
+ assert_equal false, oo.font(9,2).underline?
4951
+
4952
+ # bolded row, italic col
4953
+ assert_equal true, oo.font(10,3).bold?
4954
+ assert_equal true, oo.font(10,3).italic?
4955
+ assert_equal false, oo.font(10,3).underline?
4956
+
4957
+ # normal
4958
+ assert_equal false, oo.font(11,4).bold?
4959
+ assert_equal false, oo.font(11,4).italic?
4960
+ assert_equal false, oo.font(11,4).underline?
4961
+ end
4962
+
4963
+ def test_cell_styles
4964
+ if OPENOFFICE
4965
+ oo = Openoffice.new(File.join(TESTDIR,"style.ods"))
4966
+ verify_cell_fonts(oo)
4967
+ end
4968
+ if EXCELX
4969
+ oo = Excelx.new(File.join(TESTDIR,"style.xlsx"))
4970
+ verify_cell_fonts(oo)
4971
+ end
4972
+ if EXCEL
4973
+ oo = Excel.new(File.join(TESTDIR,"style.xls"))
4974
+ verify_cell_fonts(oo)
4975
+ end
4976
+ end
4977
+
4978
+ # If a cell has a date-like string but is preceeded by a '
4979
+ # to force that date to be treated like a string, we were getting an exception.
4980
+ # This test just checks for that exception to make sure it's not raised in this cas
4981
+ def test_date_to_float_conversion
4982
+ if EXCEL
4983
+ assert_nothing_raised(NoMethodError) do
4984
+ oo = Excel.new(File.join(TESTDIR,"datetime_floatconv.xls"))
4985
+ oo.default_sheet = oo.sheets.first
4986
+ oo.cell('a',1)
4987
+ oo.cell('a',2)
4988
+ end
4989
+ end
4990
+ end
4991
+
4833
4992
  end # class