roo 0.9.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/History.txt +6 -0
  2. data/License.txt +0 -0
  3. data/Manifest.txt +8 -0
  4. data/README.txt +0 -0
  5. data/Rakefile +0 -0
  6. data/base64include.rb +0 -0
  7. data/examples/roo_soap_client.rb +0 -0
  8. data/examples/roo_soap_server.rb +0 -0
  9. data/examples/write_me.rb +0 -0
  10. data/lib/roo.rb +1 -0
  11. data/lib/roo/excel.rb +0 -0
  12. data/lib/roo/excelx.rb +426 -0
  13. data/lib/roo/generic_spreadsheet.rb +5 -5
  14. data/lib/roo/google.rb +0 -0
  15. data/lib/roo/openoffice.rb +0 -0
  16. data/lib/roo/roo_rails_helper.rb +0 -0
  17. data/lib/roo/version.rb +3 -3
  18. data/scripts/txt2html +0 -0
  19. data/setup.rb +0 -0
  20. data/test/Bibelbund.csv +0 -0
  21. data/test/Bibelbund.ods +0 -0
  22. data/test/Bibelbund.xls +0 -0
  23. data/test/Bibelbund1.ods +0 -0
  24. data/test/bbu.ods +0 -0
  25. data/test/bbu.xls +0 -0
  26. data/test/bbu.xlsx +0 -0
  27. data/test/bode-v1.ods.zip +0 -0
  28. data/test/bode-v1.xls.zip +0 -0
  29. data/test/borders.ods +0 -0
  30. data/test/borders.xls +0 -0
  31. data/test/borders.xlsx +0 -0
  32. data/test/formula.ods +0 -0
  33. data/test/formula.xls +0 -0
  34. data/test/formula.xlsx +0 -0
  35. data/test/no_spreadsheet_file.txt +0 -0
  36. data/test/numbers1.csv +0 -0
  37. data/test/numbers1.ods +0 -0
  38. data/test/numbers1.xls +0 -0
  39. data/test/numbers1.xlsx +0 -0
  40. data/test/numbers1_excel.csv +0 -0
  41. data/test/only_one_sheet.ods +0 -0
  42. data/test/only_one_sheet.xls +0 -0
  43. data/test/only_one_sheet.xlsx +0 -0
  44. data/test/ric.ods +0 -0
  45. data/test/simple_spreadsheet.ods +0 -0
  46. data/test/simple_spreadsheet.xls +0 -0
  47. data/test/simple_spreadsheet.xlsx +0 -0
  48. data/test/simple_spreadsheet_from_italo.ods +0 -0
  49. data/test/simple_spreadsheet_from_italo.xls +0 -0
  50. data/test/test_helper.rb +0 -0
  51. data/test/test_roo.rb +1252 -265
  52. data/test/time-test.csv +0 -0
  53. data/test/time-test.ods +0 -0
  54. data/test/time-test.xls +0 -0
  55. data/test/time-test.xlsx +0 -0
  56. data/website/index.html +9 -11
  57. data/website/index.txt +7 -12
  58. data/website/javascripts/rounded_corners_lite.inc.js +0 -0
  59. data/website/stylesheets/screen.css +0 -0
  60. data/website/template.rhtml +0 -0
  61. metadata +10 -2
@@ -181,7 +181,7 @@ class GenericSpreadsheet
181
181
  y,x = key.split(',')
182
182
  y = y.to_i
183
183
  result = [result, y].max if value
184
- }
184
+ } if @cell[sheet]
185
185
  result = nil if result == impossible_value
186
186
  @last_row[sheet] = result
187
187
  result
@@ -203,7 +203,7 @@ class GenericSpreadsheet
203
203
  y,x = key.split(',')
204
204
  x = x.to_i
205
205
  result = [result, x].max if value
206
- }
206
+ } if @cell[sheet]
207
207
  result = nil if result == impossible_value
208
208
  @last_column[sheet] = result
209
209
  result
@@ -220,11 +220,11 @@ class GenericSpreadsheet
220
220
  end
221
221
  impossible_value = 999_999 # more than a spreadsheet can hold
222
222
  result = impossible_value
223
- @cell[sheet].each_pair {|key,value|
223
+ @cell[sheet].each_pair {|key,value|
224
224
  y,x = key.split(',')
225
225
  y = y.to_i
226
226
  result = [result, y].min if value
227
- }
227
+ } if @cell[sheet]
228
228
  result = nil if result == impossible_value
229
229
  @first_row[sheet] = result
230
230
  result
@@ -245,7 +245,7 @@ class GenericSpreadsheet
245
245
  y,x = key.split(',')
246
246
  x = x.to_i
247
247
  result = [result, x].min if value
248
- }
248
+ } if @cell[sheet]
249
249
  result = nil if result == impossible_value
250
250
  @first_column[sheet] = result
251
251
  result
data/lib/roo/google.rb CHANGED
File without changes
File without changes
File without changes
data/lib/roo/version.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module Roo #:nodoc:
2
2
  module VERSION #:nodoc:
3
- MAJOR = 0
4
- MINOR = 9
5
- TINY = 4
3
+ MAJOR = 1
4
+ MINOR = 0
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/scripts/txt2html CHANGED
File without changes
data/setup.rb CHANGED
File without changes
data/test/Bibelbund.csv CHANGED
File without changes
data/test/Bibelbund.ods CHANGED
File without changes
data/test/Bibelbund.xls CHANGED
File without changes
data/test/Bibelbund1.ods CHANGED
File without changes
data/test/bbu.ods CHANGED
File without changes
data/test/bbu.xls CHANGED
File without changes
data/test/bbu.xlsx ADDED
Binary file
data/test/bode-v1.ods.zip CHANGED
File without changes
data/test/bode-v1.xls.zip CHANGED
File without changes
data/test/borders.ods CHANGED
File without changes
data/test/borders.xls CHANGED
File without changes
data/test/borders.xlsx ADDED
Binary file
data/test/formula.ods CHANGED
File without changes
data/test/formula.xls CHANGED
File without changes
data/test/formula.xlsx ADDED
Binary file
File without changes
data/test/numbers1.csv CHANGED
File without changes
data/test/numbers1.ods CHANGED
File without changes
data/test/numbers1.xls CHANGED
File without changes
Binary file
File without changes
File without changes
File without changes
Binary file
data/test/ric.ods CHANGED
File without changes
File without changes
File without changes
Binary file
File without changes
File without changes
data/test/test_helper.rb CHANGED
File without changes
data/test/test_roo.rb CHANGED
@@ -119,6 +119,7 @@ class TestRoo < Test::Unit::TestCase
119
119
  EXCEL = true # do Excel Tests?
120
120
  GOOGLE = false # do Google-Spreadsheet Tests?
121
121
  GNUMERIC_ODS = false # do gnumeric with ods files Tests?
122
+ EXCELX = true # do Excel-X Tests? (.xlsx-files)
122
123
 
123
124
  OPENOFFICEWRITE = false # experimental: write access with OO-Documents
124
125
  ONLINE = false
@@ -169,6 +170,10 @@ class TestRoo < Test::Unit::TestCase
169
170
  oo = Google.new(key_of("numbers1"))
170
171
  assert_kind_of Google, oo
171
172
  end
173
+ if EXCELX
174
+ oo = Excelx.new(File.join("test","numbers1.xlsx"))
175
+ assert_kind_of Excelx, oo
176
+ end
172
177
  end
173
178
 
174
179
  def test_letters
@@ -242,6 +247,23 @@ class TestRoo < Test::Unit::TestCase
242
247
  end
243
248
  end
244
249
 
250
+ def test_sheets_excelx
251
+ if EXCELX
252
+ oo = Excelx.new(File.join("test","numbers1.xlsx"))
253
+ assert_equal ["Tabelle1","Name of Sheet 2","Sheet3","Sheet4","Sheet5"], oo.sheets
254
+ assert_raise(RangeError) {
255
+ oo.default_sheet = "no_sheet"
256
+ }
257
+ assert_raise(TypeError) {
258
+ oo.default_sheet = [1,2,3]
259
+ }
260
+ oo.sheets.each { |sh|
261
+ oo.default_sheet = sh
262
+ assert_equal sh, oo.default_sheet
263
+ }
264
+ end
265
+ end
266
+
245
267
  def test_sheets_google
246
268
  if GOOGLE
247
269
  oo = Google.new(key_of("numbers1"))
@@ -376,6 +398,47 @@ class TestRoo < Test::Unit::TestCase
376
398
  end
377
399
  end
378
400
 
401
+ def test_cell_excelx
402
+ if EXCELX
403
+ oo = Excelx.new(File.join("test","numbers1.xlsx"))
404
+ oo.default_sheet = oo.sheets.first
405
+
406
+ assert_kind_of Float, oo.cell(1,1)
407
+ assert_equal 1, oo.cell(1,1)
408
+ assert_equal 2, oo.cell(1,2)
409
+ assert_equal 3, oo.cell(1,3)
410
+ assert_equal 4, oo.cell(1,4)
411
+ assert_equal 5, oo.cell(2,1)
412
+ assert_equal 6, oo.cell(2,2)
413
+ assert_equal 7, oo.cell(2,3)
414
+ assert_equal 8, oo.cell(2,4)
415
+ assert_equal 9, oo.cell(2,5)
416
+ assert_equal "test", oo.cell(2,6)
417
+ # assert_equal "string", oo.celltype(2,6)
418
+ assert_equal :string, oo.celltype(2,6)
419
+ assert_equal 11, oo.cell(2,7)
420
+ # assert_equal "float", oo.celltype(2,7)
421
+ assert_equal :float, oo.celltype(2,7)
422
+
423
+ assert_equal 10, oo.cell(4,1)
424
+ assert_equal 11, oo.cell(4,2)
425
+ assert_equal 12, oo.cell(4,3)
426
+ assert_equal 13, oo.cell(4,4)
427
+ assert_equal 14, oo.cell(4,5)
428
+
429
+ assert_equal 10, oo.cell(4,'A')
430
+ assert_equal 11, oo.cell(4,'B')
431
+ assert_equal 12, oo.cell(4,'C')
432
+ assert_equal 13, oo.cell(4,'D')
433
+ assert_equal 14, oo.cell(4,'E')
434
+
435
+ # assert_equal "date", oo.celltype(5,1)
436
+ assert_equal :date, oo.celltype(5,1)
437
+ assert_equal Date.new(1961,11,21), oo.cell(5,1)
438
+ assert_equal "1961-11-21", oo.cell(5,1).to_s
439
+ end
440
+ end
441
+
379
442
  def test_cell_google
380
443
  if GOOGLE
381
444
  oo = Google.new(key_of("numbers1"))
@@ -437,6 +500,11 @@ class TestRoo < Test::Unit::TestCase
437
500
  oo.default_sheet = oo.sheets.first
438
501
  assert_equal :string, oo.celltype(2,6)
439
502
  end
503
+ if EXCELX
504
+ oo = Excelx.new(File.join("test","numbers1.xlsx"))
505
+ oo.default_sheet = oo.sheets.first
506
+ assert_equal :string, oo.celltype(2,6)
507
+ end
440
508
  end
441
509
 
442
510
  def test_cell_address
@@ -517,6 +585,33 @@ class TestRoo < Test::Unit::TestCase
517
585
  #assert_equal "lulua", oo.cell('b',10)
518
586
  end
519
587
 
588
+ if EXCELX
589
+ oo = Excelx.new(File.join("test","numbers1.xlsx"))
590
+ oo.default_sheet = oo.sheets.first
591
+ assert_equal "tata", oo.cell(6,1)
592
+ assert_equal "tata", oo.cell(6,'A')
593
+ assert_equal "tata", oo.cell('A',6)
594
+ assert_equal "tata", oo.cell(6,'a')
595
+ assert_equal "tata", oo.cell('a',6)
596
+
597
+ assert_raise(ArgumentError) {
598
+ assert_equal "tata", oo.cell('a','f')
599
+ }
600
+ assert_raise(ArgumentError) {
601
+ assert_equal "tata", oo.cell('f','a')
602
+ }
603
+
604
+ assert_equal "thisisc8", oo.cell(8,3)
605
+ assert_equal "thisisc8", oo.cell(8,'C')
606
+ assert_equal "thisisc8", oo.cell('C',8)
607
+ assert_equal "thisisc8", oo.cell(8,'c')
608
+ assert_equal "thisisc8", oo.cell('c',8)
609
+
610
+ assert_equal "thisisd9", oo.cell('d',9)
611
+ assert_equal "thisisa11", oo.cell('a',11)
612
+ #assert_equal "lulua", oo.cell('b',10)
613
+ end
614
+
520
615
  if GOOGLE
521
616
  oo = Google.new(key_of("numbers1"))
522
617
  oo.default_sheet = oo.sheets.first
@@ -557,11 +652,15 @@ class TestRoo < Test::Unit::TestCase
557
652
  if EXCEL
558
653
  # excel does not have a officeversion
559
654
  end
655
+ if EXCELX
656
+ # excelx does not have a officeversion
657
+ #TODO: gibt es hier eine Versionsnummer
658
+ end
560
659
  if GOOGLE
561
660
  # google does not have a officeversion
562
661
  end
563
662
  end
564
-
663
+
565
664
  #TODO: inkonsequente Lieferung Fixnum/Float
566
665
  def test_rows
567
666
  if OPENOFFICE
@@ -617,6 +716,26 @@ class TestRoo < Test::Unit::TestCase
617
716
  "vierundvierzig",
618
717
  "fuenfundvierzig"], oo.row(16)
619
718
  end
719
+ if EXCELX
720
+ oo = Excelx.new(File.join("test","numbers1.xlsx"))
721
+ oo.default_sheet = oo.sheets.first
722
+ assert_equal 41, oo.cell('a',12)
723
+ assert_equal 42, oo.cell('b',12)
724
+ assert_equal 43, oo.cell('c',12)
725
+ assert_equal 44, oo.cell('d',12)
726
+ assert_equal 45, oo.cell('e',12)
727
+ assert_equal [41,42,43,44,45], oo.row(12)
728
+ assert_equal "einundvierzig", oo.cell('a',16)
729
+ assert_equal "zweiundvierzig", oo.cell('b',16)
730
+ assert_equal "dreiundvierzig", oo.cell('c',16)
731
+ assert_equal "vierundvierzig", oo.cell('d',16)
732
+ assert_equal "fuenfundvierzig", oo.cell('e',16)
733
+ assert_equal ["einundvierzig",
734
+ "zweiundvierzig",
735
+ "dreiundvierzig",
736
+ "vierundvierzig",
737
+ "fuenfundvierzig"], oo.row(16)
738
+ end
620
739
  if GOOGLE
621
740
  oo = Google.new(key_of("numbers1"))
622
741
  oo.default_sheet = oo.sheets.first
@@ -655,6 +774,11 @@ class TestRoo < Test::Unit::TestCase
655
774
  oo.default_sheet = oo.sheets.first
656
775
  assert_equal 18, oo.last_row
657
776
  end
777
+ if EXCELX
778
+ oo = Excelx.new(File.join("test","numbers1.xlsx"))
779
+ oo.default_sheet = oo.sheets.first
780
+ assert_equal 18, oo.last_row
781
+ end
658
782
  if GOOGLE
659
783
  oo = Google.new(key_of("numbers1"))
660
784
  oo.default_sheet = oo.sheets.first
@@ -678,6 +802,11 @@ class TestRoo < Test::Unit::TestCase
678
802
  oo.default_sheet = oo.sheets.first
679
803
  assert_equal 7, oo.last_column
680
804
  end
805
+ if EXCELX
806
+ oo = Excelx.new(File.join("test","numbers1.xlsx"))
807
+ oo.default_sheet = oo.sheets.first
808
+ assert_equal 7, oo.last_column
809
+ end
681
810
  if GOOGLE
682
811
  oo = Google.new(key_of("numbers1"))
683
812
  oo.default_sheet = oo.sheets.first
@@ -701,6 +830,11 @@ class TestRoo < Test::Unit::TestCase
701
830
  oo.default_sheet = 1 # oo.sheets.first
702
831
  assert_equal 'G', oo.last_column_as_letter
703
832
  end
833
+ if EXCELX
834
+ oo = Excelx.new(File.join("test","numbers1.xlsx"))
835
+ oo.default_sheet = oo.sheets.first
836
+ assert_equal 'G', oo.last_column_as_letter
837
+ end
704
838
  if GOOGLE
705
839
  oo = Google.new(key_of("numbers1"))
706
840
  oo.default_sheet = oo.sheets.first
@@ -724,6 +858,11 @@ class TestRoo < Test::Unit::TestCase
724
858
  oo.default_sheet = 1 # oo.sheets.first
725
859
  assert_equal 1, oo.first_row
726
860
  end
861
+ if EXCELX
862
+ oo = Excelx.new(File.join("test","numbers1.xlsx"))
863
+ oo.default_sheet = oo.sheets.first
864
+ assert_equal 1, oo.first_row
865
+ end
727
866
  if GOOGLE
728
867
  oo = Google.new(key_of("numbers1"))
729
868
  oo.default_sheet = oo.sheets.first
@@ -743,11 +882,15 @@ class TestRoo < Test::Unit::TestCase
743
882
  assert_equal 1, oo.first_column
744
883
  end
745
884
  if EXCEL
746
- #-- Excel
747
885
  oo = Excel.new(File.join("test","numbers1.xls"))
748
886
  oo.default_sheet = 1 # oo.sheets.first
749
887
  assert_equal 1, oo.first_column
750
888
  end
889
+ if EXCELX
890
+ oo = Excelx.new(File.join("test","numbers1.xlsx"))
891
+ oo.default_sheet = oo.sheets.first
892
+ assert_equal 1, oo.first_column
893
+ end
751
894
  if GOOGLE
752
895
  assert_nothing_raised(Timeout::Error) {
753
896
  Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
@@ -783,6 +926,14 @@ class TestRoo < Test::Unit::TestCase
783
926
  end
784
927
  end
785
928
 
929
+ def test_first_column_as_letter_excelx
930
+ if EXCELX
931
+ oo = Excelx.new(File.join("test","numbers1.xlsx"))
932
+ oo.default_sheet = oo.sheets.first
933
+ assert_equal 'A', oo.first_column_as_letter
934
+ end
935
+ end
936
+
786
937
  def test_first_column_as_letter_google
787
938
  if GOOGLE
788
939
  oo = Google.new(key_of("numbers1"))
@@ -807,6 +958,11 @@ class TestRoo < Test::Unit::TestCase
807
958
  oo.default_sheet = "Name of Sheet 2"
808
959
  assert_equal 'I am sheet 2', oo.cell('C',5)
809
960
  end
961
+ if EXCELX
962
+ oo = Excelx.new(File.join("test","numbers1.xlsx"))
963
+ oo.default_sheet = "Name of Sheet 2"
964
+ assert_equal 'I am sheet 2', oo.cell('C',5)
965
+ end
810
966
  if GOOGLE
811
967
  oo = Google.new(key_of("numbers1"))
812
968
  oo.default_sheet = "Name of Sheet 2"
@@ -843,6 +999,15 @@ class TestRoo < Test::Unit::TestCase
843
999
  assert_equal 'E', oo.last_column_as_letter
844
1000
  assert_equal 14, oo.last_row
845
1001
  end
1002
+ if EXCELX
1003
+ oo = Excelx.new(File.join("test","numbers1.xlsx"))
1004
+ oo.default_sheet = "Name of Sheet 2"
1005
+ assert_equal 2, oo.first_column
1006
+ assert_equal 'B', oo.first_column_as_letter
1007
+ assert_equal 5, oo.first_row
1008
+ assert_equal 'E', oo.last_column_as_letter
1009
+ assert_equal 14, oo.last_row
1010
+ end
846
1011
  end
847
1012
 
848
1013
  def test_multiple_letters
@@ -873,6 +1038,15 @@ class TestRoo < Test::Unit::TestCase
873
1038
  assert_equal 'BA', oo.last_column_as_letter
874
1039
  assert_equal "i am BA", oo.cell(1,'BA')
875
1040
  end
1041
+ if EXCELX
1042
+ oo = Excelx.new(File.join("test","numbers1.xlsx"))
1043
+ oo.default_sheet = "Sheet3"
1044
+ assert_equal "i am AA", oo.cell('AA',1)
1045
+ assert_equal "i am AB", oo.cell('AB',1)
1046
+ assert_equal "i am BA", oo.cell('BA',1)
1047
+ assert_equal 'BA', oo.last_column_as_letter
1048
+ assert_equal "i am BA", oo.cell(1,'BA')
1049
+ end
876
1050
  end
877
1051
 
878
1052
  def test_argument_error
@@ -908,13 +1082,19 @@ class TestRoo < Test::Unit::TestCase
908
1082
  assert oo.empty?('a',20)
909
1083
  end
910
1084
  if EXCEL
911
- #-- Excel
912
1085
  oo = Excel.new(File.join("test","numbers1.xls"))
913
1086
  oo.default_sheet = 1
914
1087
  assert oo.empty?('a',14)
915
1088
  assert ! oo.empty?('a',15)
916
1089
  assert oo.empty?('a',20)
917
1090
  end
1091
+ if EXCELX
1092
+ oo = Excelx.new(File.join("test","numbers1.xlsx"))
1093
+ oo.default_sheet = oo.sheets.first
1094
+ assert oo.empty?('a',14)
1095
+ assert ! oo.empty?('a',15)
1096
+ assert oo.empty?('a',20)
1097
+ end
918
1098
  end
919
1099
 
920
1100
  def test_writeopenoffice
@@ -976,6 +1156,14 @@ class TestRoo < Test::Unit::TestCase
976
1156
  oo.default_sheet = 1 # oo.sheets.first
977
1157
  assert_equal 1, oo.cell(1,1)
978
1158
 
1159
+ oo.reload
1160
+ assert_equal 1, oo.cell(1,1)
1161
+ end
1162
+ if EXCELX
1163
+ oo = Excelx.new(File.join("test","numbers1.xlsx"))
1164
+ oo.default_sheet = oo.sheets.first
1165
+ assert_equal 1, oo.cell(1,1)
1166
+
979
1167
  oo.reload
980
1168
  assert_equal 1, oo.cell(1,1)
981
1169
  end
@@ -1062,6 +1250,15 @@ class TestRoo < Test::Unit::TestCase
1062
1250
  assert_equal 2, oo.cell('a',2)
1063
1251
  assert_equal 3, oo.cell('a',3)
1064
1252
  end
1253
+ if EXCELX
1254
+ oo = Excelx.new(File.join("test","numbers1.xlsx"))
1255
+ oo.default_sheet = oo.sheets[5-1]
1256
+ assert_equal 1, oo.cell('A',1)
1257
+ assert_equal 5, oo.cell('b',1)
1258
+ assert_equal 5, oo.cell('c',1)
1259
+ assert_equal 2, oo.cell('a',2)
1260
+ assert_equal 3, oo.cell('a',3)
1261
+ end
1065
1262
  #if GOOGLE
1066
1263
  # oo = Google.new(key_of("numbers1"))
1067
1264
  # oo.default_sheet = "Sheet5"
@@ -1072,142 +1269,144 @@ class TestRoo < Test::Unit::TestCase
1072
1269
  # assert_equal 3, oo.cell('a',3)
1073
1270
  #end
1074
1271
  end
1272
+
1075
1273
  #2008-01-30
1076
1274
  def test_italo_table
1077
- local_only do
1078
- oo = Openoffice.new(File.join("test","simple_spreadsheet_from_italo.ods"))
1079
- oo.default_sheet = oo.sheets.first
1080
-
1081
- assert_equal '1', oo.cell('A',1)
1082
- assert_equal '1', oo.cell('B',1)
1083
- assert_equal '1', oo.cell('C',1)
1084
-
1085
- # assert_equal 1, oo.cell('A',2)
1086
- # assert_equal 2, oo.cell('B',2)
1087
- # assert_equal 1, oo.cell('C',2)
1088
- # are stored as strings, not numbers
1089
-
1090
- assert_equal 1, oo.cell('A',2).to_i
1091
- assert_equal 2, oo.cell('B',2).to_i
1092
- assert_equal 1, oo.cell('C',2).to_i
1093
-
1094
- assert_equal 1, oo.cell('A',3)
1095
- assert_equal 3, oo.cell('B',3)
1096
- assert_equal 1, oo.cell('C',3)
1097
-
1098
- assert_equal 'A', oo.cell('A',4)
1099
- assert_equal 'A', oo.cell('B',4)
1100
- assert_equal 'A', oo.cell('C',4)
1101
-
1102
- # assert_equal '0.01', oo.cell('A',5)
1103
- # assert_equal '0.01', oo.cell('B',5)
1104
- # assert_equal '0.01', oo.cell('C',5)
1105
- #
1106
- assert_equal 0.01, oo.cell('A',5)
1107
- assert_equal 0.01, oo.cell('B',5)
1108
- assert_equal 0.01, oo.cell('C',5)
1109
-
1110
- assert_equal 0.03, oo.cell('a',5)+oo.cell('b',5)+oo.cell('c',5)
1111
-
1112
-
1113
- # 1.0
1114
-
1115
- # Cells values in row 1:
1116
- assert_equal "1:string", oo.cell(1, 1)+":"+oo.celltype(1, 1).to_s
1117
- assert_equal "1:string",oo.cell(1, 2)+":"+oo.celltype(1, 2).to_s
1118
- assert_equal "1:string",oo.cell(1, 3)+":"+oo.celltype(1, 3).to_s
1119
-
1120
- # Cells values in row 2:
1121
- assert_equal "1:string",oo.cell(2, 1)+":"+oo.celltype(2, 1).to_s
1122
- assert_equal "2:string",oo.cell(2, 2)+":"+oo.celltype(2, 2).to_s
1123
- assert_equal "1:string",oo.cell(2, 3)+":"+oo.celltype(2, 3).to_s
1124
-
1125
- # Cells values in row 3:
1126
- assert_equal "1.0:float",oo.cell(3, 1).to_s+":"+oo.celltype(3, 1).to_s
1127
- assert_equal "3.0:float",oo.cell(3, 2).to_s+":"+oo.celltype(3, 2).to_s
1128
- assert_equal "1.0:float",oo.cell(3, 3).to_s+":"+oo.celltype(3, 3).to_s
1129
-
1130
- # Cells values in row 4:
1131
- assert_equal "A:string",oo.cell(4, 1)+":"+oo.celltype(4, 1).to_s
1132
- assert_equal "A:string",oo.cell(4, 2)+":"+oo.celltype(4, 2).to_s
1133
- assert_equal "A:string",oo.cell(4, 3)+":"+oo.celltype(4, 3).to_s
1134
-
1135
- # Cells values in row 5:
1136
- assert_equal "0.01:percentage",oo.cell(5, 1).to_s+":"+oo.celltype(5, 1).to_s
1137
- assert_equal "0.01:percentage",oo.cell(5, 2).to_s+":"+oo.celltype(5, 2).to_s
1138
- assert_equal "0.01:percentage",oo.cell(5, 3).to_s+":"+oo.celltype(5, 3).to_s
1275
+ after Date.new(2008,5,30) do
1276
+ local_only do
1277
+ oo = Openoffice.new(File.join("test","simple_spreadsheet_from_italo.ods"))
1278
+ oo.default_sheet = oo.sheets.first
1139
1279
 
1140
- oo = Excel.new(File.join("test","simple_spreadsheet_from_italo.xls"))
1141
- oo.default_sheet = oo.sheets.first
1280
+ assert_equal '1', oo.cell('A',1)
1281
+ assert_equal '1', oo.cell('B',1)
1282
+ assert_equal '1', oo.cell('C',1)
1142
1283
 
1143
- assert_equal '1', oo.cell('A',1)
1144
- assert_equal '1', oo.cell('B',1)
1145
- assert_equal '1', oo.cell('C',1)
1284
+ # assert_equal 1, oo.cell('A',2)
1285
+ # assert_equal 2, oo.cell('B',2)
1286
+ # assert_equal 1, oo.cell('C',2)
1287
+ # are stored as strings, not numbers
1146
1288
 
1147
- # assert_equal 1, oo.cell('A',2)
1148
- # assert_equal 2, oo.cell('B',2)
1149
- # assert_equal 1, oo.cell('C',2)
1150
- # are stored as strings, not numbers
1289
+ assert_equal 1, oo.cell('A',2).to_i
1290
+ assert_equal 2, oo.cell('B',2).to_i
1291
+ assert_equal 1, oo.cell('C',2).to_i
1151
1292
 
1152
- assert_equal 1, oo.cell('A',2).to_i
1153
- assert_equal 2, oo.cell('B',2).to_i
1154
- assert_equal 1, oo.cell('C',2).to_i
1293
+ assert_equal 1, oo.cell('A',3)
1294
+ assert_equal 3, oo.cell('B',3)
1295
+ assert_equal 1, oo.cell('C',3)
1155
1296
 
1156
- assert_equal 1, oo.cell('A',3)
1157
- assert_equal 3, oo.cell('B',3)
1158
- assert_equal 1, oo.cell('C',3)
1297
+ assert_equal 'A', oo.cell('A',4)
1298
+ assert_equal 'A', oo.cell('B',4)
1299
+ assert_equal 'A', oo.cell('C',4)
1159
1300
 
1160
- assert_equal 'A', oo.cell('A',4)
1161
- assert_equal 'A', oo.cell('B',4)
1162
- assert_equal 'A', oo.cell('C',4)
1301
+ # assert_equal '0.01', oo.cell('A',5)
1302
+ # assert_equal '0.01', oo.cell('B',5)
1303
+ # assert_equal '0.01', oo.cell('C',5)
1304
+ #
1305
+ assert_equal 0.01, oo.cell('A',5)
1306
+ assert_equal 0.01, oo.cell('B',5)
1307
+ assert_equal 0.01, oo.cell('C',5)
1163
1308
 
1164
- # assert_equal '0.01', oo.cell('A',5)
1165
- # assert_equal '0.01', oo.cell('B',5)
1166
- # assert_equal '0.01', oo.cell('C',5)
1167
- #
1168
- assert_equal 0.01, oo.cell('A',5)
1169
- assert_equal 0.01, oo.cell('B',5)
1170
- assert_equal 0.01, oo.cell('C',5)
1309
+ assert_equal 0.03, oo.cell('a',5)+oo.cell('b',5)+oo.cell('c',5)
1171
1310
 
1172
- assert_equal 0.03, oo.cell('a',5)+oo.cell('b',5)+oo.cell('c',5)
1173
1311
 
1312
+ # 1.0
1174
1313
 
1175
- # 1.0
1314
+ # Cells values in row 1:
1315
+ assert_equal "1:string", oo.cell(1, 1)+":"+oo.celltype(1, 1).to_s
1316
+ assert_equal "1:string",oo.cell(1, 2)+":"+oo.celltype(1, 2).to_s
1317
+ assert_equal "1:string",oo.cell(1, 3)+":"+oo.celltype(1, 3).to_s
1176
1318
 
1177
- # Cells values in row 1:
1178
- assert_equal "1:string", oo.cell(1, 1)+":"+oo.celltype(1, 1).to_s
1179
- assert_equal "1:string",oo.cell(1, 2)+":"+oo.celltype(1, 2).to_s
1180
- assert_equal "1:string",oo.cell(1, 3)+":"+oo.celltype(1, 3).to_s
1319
+ # Cells values in row 2:
1320
+ assert_equal "1:string",oo.cell(2, 1)+":"+oo.celltype(2, 1).to_s
1321
+ assert_equal "2:string",oo.cell(2, 2)+":"+oo.celltype(2, 2).to_s
1322
+ assert_equal "1:string",oo.cell(2, 3)+":"+oo.celltype(2, 3).to_s
1181
1323
 
1182
- # Cells values in row 2:
1183
- assert_equal "1:string",oo.cell(2, 1)+":"+oo.celltype(2, 1).to_s
1184
- assert_equal "2:string",oo.cell(2, 2)+":"+oo.celltype(2, 2).to_s
1185
- assert_equal "1:string",oo.cell(2, 3)+":"+oo.celltype(2, 3).to_s
1324
+ # Cells values in row 3:
1325
+ assert_equal "1.0:float",oo.cell(3, 1).to_s+":"+oo.celltype(3, 1).to_s
1326
+ assert_equal "3.0:float",oo.cell(3, 2).to_s+":"+oo.celltype(3, 2).to_s
1327
+ assert_equal "1.0:float",oo.cell(3, 3).to_s+":"+oo.celltype(3, 3).to_s
1186
1328
 
1187
- # Cells values in row 3:
1188
- assert_equal "1.0:float",oo.cell(3, 1).to_s+":"+oo.celltype(3, 1).to_s
1189
- assert_equal "3.0:float",oo.cell(3, 2).to_s+":"+oo.celltype(3, 2).to_s
1190
- assert_equal "1.0:float",oo.cell(3, 3).to_s+":"+oo.celltype(3, 3).to_s
1329
+ # Cells values in row 4:
1330
+ assert_equal "A:string",oo.cell(4, 1)+":"+oo.celltype(4, 1).to_s
1331
+ assert_equal "A:string",oo.cell(4, 2)+":"+oo.celltype(4, 2).to_s
1332
+ assert_equal "A:string",oo.cell(4, 3)+":"+oo.celltype(4, 3).to_s
1191
1333
 
1192
- # Cells values in row 4:
1193
- assert_equal "A:string",oo.cell(4, 1)+":"+oo.celltype(4, 1).to_s
1194
- assert_equal "A:string",oo.cell(4, 2)+":"+oo.celltype(4, 2).to_s
1195
- assert_equal "A:string",oo.cell(4, 3)+":"+oo.celltype(4, 3).to_s
1334
+ # Cells values in row 5:
1335
+ assert_equal "0.01:percentage",oo.cell(5, 1).to_s+":"+oo.celltype(5, 1).to_s
1336
+ assert_equal "0.01:percentage",oo.cell(5, 2).to_s+":"+oo.celltype(5, 2).to_s
1337
+ assert_equal "0.01:percentage",oo.cell(5, 3).to_s+":"+oo.celltype(5, 3).to_s
1196
1338
 
1197
- # Cells values in row 5:
1198
- #assert_equal "0.01:percentage",oo.cell(5, 1).to_s+":"+oo.celltype(5, 1).to_s
1199
- #assert_equal "0.01:percentage",oo.cell(5, 2).to_s+":"+oo.celltype(5, 2).to_s
1200
- #assert_equal "0.01:percentage",oo.cell(5, 3).to_s+":"+oo.celltype(5, 3).to_s
1201
- # why do we get floats here? in the spreadsheet the cells were defined
1202
- # to be percentage
1203
- # TODO: should be fixed
1204
- # the excel gem does not support the cell type 'percentage' these
1205
- # cells are returned to be of the type float.
1206
- assert_equal "0.01:float",oo.cell(5, 1).to_s+":"+oo.celltype(5, 1).to_s
1207
- assert_equal "0.01:float",oo.cell(5, 2).to_s+":"+oo.celltype(5, 2).to_s
1208
- assert_equal "0.01:float",oo.cell(5, 3).to_s+":"+oo.celltype(5, 3).to_s
1209
- end
1339
+ oo = Excel.new(File.join("test","simple_spreadsheet_from_italo.xls"))
1340
+ oo.default_sheet = oo.sheets.first
1210
1341
 
1342
+ assert_equal '1', oo.cell('A',1)
1343
+ assert_equal '1', oo.cell('B',1)
1344
+ assert_equal '1', oo.cell('C',1)
1345
+
1346
+ # assert_equal 1, oo.cell('A',2)
1347
+ # assert_equal 2, oo.cell('B',2)
1348
+ # assert_equal 1, oo.cell('C',2)
1349
+ # are stored as strings, not numbers
1350
+
1351
+ assert_equal 1, oo.cell('A',2).to_i
1352
+ assert_equal 2, oo.cell('B',2).to_i
1353
+ assert_equal 1, oo.cell('C',2).to_i
1354
+
1355
+ assert_equal 1, oo.cell('A',3)
1356
+ assert_equal 3, oo.cell('B',3)
1357
+ assert_equal 1, oo.cell('C',3)
1358
+
1359
+ assert_equal 'A', oo.cell('A',4)
1360
+ assert_equal 'A', oo.cell('B',4)
1361
+ assert_equal 'A', oo.cell('C',4)
1362
+
1363
+ # assert_equal '0.01', oo.cell('A',5)
1364
+ # assert_equal '0.01', oo.cell('B',5)
1365
+ # assert_equal '0.01', oo.cell('C',5)
1366
+ #
1367
+ assert_equal 0.01, oo.cell('A',5)
1368
+ assert_equal 0.01, oo.cell('B',5)
1369
+ assert_equal 0.01, oo.cell('C',5)
1370
+
1371
+ assert_equal 0.03, oo.cell('a',5)+oo.cell('b',5)+oo.cell('c',5)
1372
+
1373
+
1374
+ # 1.0
1375
+
1376
+ # Cells values in row 1:
1377
+ assert_equal "1:string", oo.cell(1, 1)+":"+oo.celltype(1, 1).to_s
1378
+ assert_equal "1:string",oo.cell(1, 2)+":"+oo.celltype(1, 2).to_s
1379
+ assert_equal "1:string",oo.cell(1, 3)+":"+oo.celltype(1, 3).to_s
1380
+
1381
+ # Cells values in row 2:
1382
+ assert_equal "1:string",oo.cell(2, 1)+":"+oo.celltype(2, 1).to_s
1383
+ assert_equal "2:string",oo.cell(2, 2)+":"+oo.celltype(2, 2).to_s
1384
+ assert_equal "1:string",oo.cell(2, 3)+":"+oo.celltype(2, 3).to_s
1385
+
1386
+ # Cells values in row 3:
1387
+ assert_equal "1.0:float",oo.cell(3, 1).to_s+":"+oo.celltype(3, 1).to_s
1388
+ assert_equal "3.0:float",oo.cell(3, 2).to_s+":"+oo.celltype(3, 2).to_s
1389
+ assert_equal "1.0:float",oo.cell(3, 3).to_s+":"+oo.celltype(3, 3).to_s
1390
+
1391
+ # Cells values in row 4:
1392
+ assert_equal "A:string",oo.cell(4, 1)+":"+oo.celltype(4, 1).to_s
1393
+ assert_equal "A:string",oo.cell(4, 2)+":"+oo.celltype(4, 2).to_s
1394
+ assert_equal "A:string",oo.cell(4, 3)+":"+oo.celltype(4, 3).to_s
1395
+
1396
+ # Cells values in row 5:
1397
+ #assert_equal "0.01:percentage",oo.cell(5, 1).to_s+":"+oo.celltype(5, 1).to_s
1398
+ #assert_equal "0.01:percentage",oo.cell(5, 2).to_s+":"+oo.celltype(5, 2).to_s
1399
+ #assert_equal "0.01:percentage",oo.cell(5, 3).to_s+":"+oo.celltype(5, 3).to_s
1400
+ # why do we get floats here? in the spreadsheet the cells were defined
1401
+ # to be percentage
1402
+ # TODO: should be fixed
1403
+ # the excel gem does not support the cell type 'percentage' these
1404
+ # cells are returned to be of the type float.
1405
+ assert_equal "0.01:float",oo.cell(5, 1).to_s+":"+oo.celltype(5, 1).to_s
1406
+ assert_equal "0.01:float",oo.cell(5, 2).to_s+":"+oo.celltype(5, 2).to_s
1407
+ assert_equal "0.01:float",oo.cell(5, 3).to_s+":"+oo.celltype(5, 3).to_s
1408
+ end
1409
+ end #after
1211
1410
  end
1212
1411
 
1213
1412
  def test_formula
@@ -1308,8 +1507,44 @@ class TestRoo < Test::Unit::TestCase
1308
1507
  [8, 2, "=SUM(R1C1:R[-1]C)"]],
1309
1508
  oo.formulas(oo.sheets.first)
1310
1509
  end # GOOGLE
1311
- end
1510
+ if EXCELX
1511
+ oo = Excelx.new(File.join("test","formula.xlsx"))
1512
+ oo.default_sheet = oo.sheets.first
1513
+ assert_equal 1, oo.cell('A',1)
1514
+ assert_equal 2, oo.cell('A',2)
1515
+ assert_equal 3, oo.cell('A',3)
1516
+ assert_equal 4, oo.cell('A',4)
1517
+ assert_equal 5, oo.cell('A',5)
1518
+ assert_equal 6, oo.cell('A',6)
1519
+ assert_equal 21, oo.cell('A',7)
1520
+ assert_equal :formula, oo.celltype('A',7)
1521
+ after Date.new(2008,6,1) do
1522
+ #steht nicht in Datei, oder?
1523
+ assert_equal "=[Sheet2.A1]", oo.formula('C',7)
1524
+ end
1525
+ assert_nil oo.formula('A',6)
1526
+ # assert_equal [[7, 1, "=SUM([.A1:.A6])"],
1527
+ # [7, 2, "=SUM([.$A$1:.B6])"],
1528
+ #[7, 3, "=[Sheet2.A1]"],
1529
+ #[8, 2, "=SUM([.$A$1:.B7])"],
1530
+ #], oo.formulas(oo.sheets.first)
1531
+ assert_equal [[7, 1, 'SUM(A1:A6)'],
1532
+ [7, 2, 'SUM($A$1:B6)'],
1533
+ # [7, 3, "=[Sheet2.A1]"],
1534
+ # [8, 2, "=SUM([.$A$1:.B7])"],
1535
+ ], oo.formulas(oo.sheets.first)
1312
1536
 
1537
+ after Date.new(2007,6,25) do
1538
+ # setting a cell
1539
+ oo.set('A',15, 41)
1540
+ assert_equal 41, oo.cell('A',15)
1541
+ oo.set('A',16, "41")
1542
+ assert_equal "41", oo.cell('A',16)
1543
+ oo.set('A',17, 42.5)
1544
+ assert_equal 42.5, oo.cell('A',17)
1545
+ end
1546
+ end
1547
+ end
1313
1548
 
1314
1549
  def test_borders_sheets_openoffice
1315
1550
  if OPENOFFICE
@@ -1356,6 +1591,29 @@ class TestRoo < Test::Unit::TestCase
1356
1591
  end
1357
1592
  end
1358
1593
 
1594
+ def test_borders_sheets_excelx
1595
+ if EXCELX
1596
+ oo = Excelx.new(File.join("test","borders.xlsx"))
1597
+ oo.default_sheet = oo.sheets[1]
1598
+ assert_equal 6, oo.first_row
1599
+ assert_equal 11, oo.last_row
1600
+ assert_equal 4, oo.first_column
1601
+ assert_equal 8, oo.last_column
1602
+
1603
+ oo.default_sheet = oo.sheets.first
1604
+ assert_equal 5, oo.first_row
1605
+ assert_equal 10, oo.last_row
1606
+ assert_equal 3, oo.first_column
1607
+ assert_equal 7, oo.last_column
1608
+
1609
+ oo.default_sheet = oo.sheets[2]
1610
+ assert_equal 7, oo.first_row
1611
+ assert_equal 12, oo.last_row
1612
+ assert_equal 5, oo.first_column
1613
+ assert_equal 9, oo.last_column
1614
+ end
1615
+ end
1616
+
1359
1617
  def test_borders_sheets_google
1360
1618
  if GOOGLE
1361
1619
  assert_nothing_raised(Timeout::Error) {
@@ -1436,6 +1694,27 @@ class TestRoo < Test::Unit::TestCase
1436
1694
  yaml_entry(16,4,"string","vierundvierzig")+
1437
1695
  yaml_entry(16,5,"string","fuenfundvierzig"), oo.to_yaml({}, 12,3)
1438
1696
  end
1697
+ if EXCELX
1698
+ oo = Excelx.new(File.join("test","numbers1.xlsx"))
1699
+ oo.default_sheet = oo.sheets.first
1700
+ assert_equal "--- \n"+yaml_entry(5,1,"date","1961-11-21"), oo.to_yaml({}, 5,1,5,1)
1701
+ assert_equal "--- \n"+yaml_entry(8,3,"string","thisisc8"), oo.to_yaml({}, 8,3,8,3)
1702
+ assert_equal "--- \n"+yaml_entry(12,3,"float",43.0), oo.to_yaml({}, 12,3,12,3)
1703
+ assert_equal \
1704
+ "--- \n"+yaml_entry(12,3,"float",43.0) +
1705
+ yaml_entry(12,4,"float",44.0) +
1706
+ yaml_entry(12,5,"float",45.0), oo.to_yaml({}, 12,3,12)
1707
+ assert_equal \
1708
+ "--- \n"+yaml_entry(12,3,"float",43.0)+
1709
+ yaml_entry(12,4,"float",44.0)+
1710
+ yaml_entry(12,5,"float",45.0)+
1711
+ yaml_entry(15,3,"float",43.0)+
1712
+ yaml_entry(15,4,"float",44.0)+
1713
+ yaml_entry(15,5,"float",45.0)+
1714
+ yaml_entry(16,3,"string","dreiundvierzig")+
1715
+ yaml_entry(16,4,"string","vierundvierzig")+
1716
+ yaml_entry(16,5,"string","fuenfundvierzig"), oo.to_yaml({}, 12,3)
1717
+ end
1439
1718
  if GOOGLE
1440
1719
  oo = Google.new(key_of("numbers1"))
1441
1720
  oo.default_sheet = oo.sheets.first
@@ -1601,6 +1880,17 @@ class TestRoo < Test::Unit::TestCase
1601
1880
  assert_equal 43, oo.cell('C',4)
1602
1881
  assert_equal 44, oo.cell('D',4)
1603
1882
  end
1883
+ if EXCELX
1884
+ oo = Excelx.new(File.join("test","only_one_sheet.xlsx"))
1885
+ # oo.default_sheet = oo.sheets.first
1886
+ assert_equal 42, oo.cell('B',4)
1887
+ assert_equal 43, oo.cell('C',4)
1888
+ assert_equal 44, oo.cell('D',4)
1889
+ oo.default_sheet = oo.sheets.first
1890
+ assert_equal 42, oo.cell('B',4)
1891
+ assert_equal 43, oo.cell('C',4)
1892
+ assert_equal 44, oo.cell('D',4)
1893
+ end
1604
1894
  if GOOGLE
1605
1895
  oo = Google.new(key_of("only_one_sheet"))
1606
1896
  # oo.default_sheet = oo.sheets.first
@@ -1626,6 +1916,20 @@ class TestRoo < Test::Unit::TestCase
1626
1916
  end
1627
1917
  end
1628
1918
 
1919
+ #TODO: xlsx-Datei anpassen!
1920
+ def test_excelx_open_from_uri_and_zipped
1921
+ after Date.new(2008,6,30) do
1922
+ if EXCELX
1923
+ if ONLINE
1924
+ url = 'http://stiny-leonhard.de/bode-v1.xlsx.zip'
1925
+ excel = Excelx.new(url, :zip)
1926
+ assert_equal 'ist "e" im Nenner von H(s)', excel.cell('b', 5)
1927
+ excel.remove_tmp # don't forget to remove the temporary files
1928
+ end
1929
+ end
1930
+ end
1931
+ end
1932
+
1629
1933
  def test_openoffice_open_from_uri_and_zipped
1630
1934
  if OPENOFFICE
1631
1935
  if ONLINE
@@ -1637,7 +1941,7 @@ class TestRoo < Test::Unit::TestCase
1637
1941
  end
1638
1942
  end
1639
1943
  end
1640
-
1944
+
1641
1945
  def test_excel_zipped
1642
1946
  if EXCEL
1643
1947
  excel = Excel.new(File.join("test","bode-v1.xls.zip"), :zip)
@@ -1647,7 +1951,19 @@ class TestRoo < Test::Unit::TestCase
1647
1951
  end
1648
1952
  end
1649
1953
 
1650
- def test_openoffice_zipped
1954
+ def test_excelx_zipped
1955
+ if EXCELX
1956
+ after Date.new(2008,6,1) do
1957
+ # diese Datei giebte es noch nicht gezippt
1958
+ excel = Excelx.new(File.join("test","bode-v1.xlsx.zip"), :zip)
1959
+ assert excel
1960
+ assert_equal 'ist "e" im Nenner von H(s)', excel.cell('b', 5)
1961
+ excel.remove_tmp # don't forget to remove the temporary files
1962
+ end
1963
+ end
1964
+ end
1965
+
1966
+ def test_openoffice_zipped
1651
1967
  if OPENOFFICE
1652
1968
  oo = Openoffice.new(File.join("test","bode-v1.ods.zip"), :zip)
1653
1969
  assert oo
@@ -1731,6 +2047,14 @@ class TestRoo < Test::Unit::TestCase
1731
2047
  oo.default_sheet = oo.sheets.first
1732
2048
  assert_equal "Tagebuch des Sekret\303\244rs. Letzte Tagung 15./16.11.75 Schweiz", oo.cell(45,'A')
1733
2049
  end
2050
+ if EXCELX
2051
+ after Date.new(2008,6,1) do
2052
+ #Datei gibt es noch nicht
2053
+ oo = Excelx.new(File.join("test","Bibelbund1.xlsx"))
2054
+ oo.default_sheet = oo.sheets.first
2055
+ assert_equal "Tagebuch des Sekret\303\244rs. Letzte Tagung 15./16.11.75 Schweiz", oo.cell(45,'A')
2056
+ end
2057
+ end
1734
2058
  end
1735
2059
 
1736
2060
  def test_huge_document_to_csv_openoffice
@@ -1770,6 +2094,23 @@ class TestRoo < Test::Unit::TestCase
1770
2094
  end # LONG_RUN
1771
2095
  end # def to_csv
1772
2096
 
2097
+ def test_huge_document_to_csv_excelx
2098
+ if LONG_RUN
2099
+ if EXCELX
2100
+ assert_nothing_raised(Timeout::Error) {
2101
+ Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
2102
+ File.delete("/tmp/Bibelbund.csv")
2103
+ oo = Excelx.new(File.join("test","Bibelbund.xlsx"))
2104
+ oo.default_sheet = oo.sheets.first
2105
+ assert oo.to_csv("/tmp/Bibelbund.csv")
2106
+ assert File.exists?("/tmp/Bibelbund.csv")
2107
+ assert_equal "", `diff test/Bibelbund.csv /tmp/Bibelbund.csv`
2108
+ end
2109
+ }
2110
+ end
2111
+ end # LONG_RUN
2112
+ end # def to_csv
2113
+
1773
2114
  def test_huge_document_to_csv_google
1774
2115
  # maybe a better example... TODO:
1775
2116
  after Date.new(2008,1,30) do
@@ -1835,6 +2176,27 @@ class TestRoo < Test::Unit::TestCase
1835
2176
  end
1836
2177
  end # def to_csv
1837
2178
 
2179
+ def test_to_csv_excelx
2180
+ if EXCELX
2181
+ #assert_nothing_raised(Timeout::Error) {
2182
+ Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
2183
+ File.delete_if_exist("/tmp/numbers1.csv")
2184
+ oo = Excelx.new(File.join("test","numbers1.xlsx"))
2185
+
2186
+ # bug?, 2008-01-15 from Troy Davis
2187
+ assert oo.to_csv("/tmp/numbers1.csv",oo.sheets.first)
2188
+ assert File.exists?("/tmp/numbers1.csv")
2189
+ assert_equal "", `diff test/numbers1.csv /tmp/numbers1.csv`
2190
+ oo.default_sheet = oo.sheets.first
2191
+ assert oo.to_csv("/tmp/numbers1.csv")
2192
+ assert File.exists?("/tmp/numbers1.csv")
2193
+ assert_equal "", `diff test/numbers1.csv /tmp/numbers1.csv`
2194
+ end
2195
+
2196
+ #}
2197
+ end
2198
+ end # def to_csv
2199
+
1838
2200
  def test_to_csv_google
1839
2201
  # maybe a better example... TODO:
1840
2202
  after Date.new(2008,3,30) do
@@ -1930,6 +2292,40 @@ class TestRoo < Test::Unit::TestCase
1930
2292
  assert_equal "ABC", oo.cell('D',6)
1931
2293
  assert_equal "ABC", oo.cell('E',6)
1932
2294
  end # Excel
2295
+ if EXCELX
2296
+ oo = Excelx.new(File.join("test","numbers1.xlsx"))
2297
+ oo.default_sheet = 'Sheet5'
2298
+ assert_equal :date, oo.celltype('A',4)
2299
+ assert_equal :date, oo.celltype('B',4)
2300
+ assert_equal :date, oo.celltype('C',4)
2301
+ assert_equal :date, oo.celltype('D',4)
2302
+ assert_equal :date, oo.celltype('E',4)
2303
+ assert_equal Date.new(2007,11,21), oo.cell('A',4)
2304
+ assert_equal Date.new(2007,11,21), oo.cell('B',4)
2305
+ assert_equal Date.new(2007,11,21), oo.cell('C',4)
2306
+ assert_equal Date.new(2007,11,21), oo.cell('D',4)
2307
+ assert_equal Date.new(2007,11,21), oo.cell('E',4)
2308
+ assert_equal :float, oo.celltype('A',5)
2309
+ assert_equal :float, oo.celltype('B',5)
2310
+ assert_equal :float, oo.celltype('C',5)
2311
+ assert_equal :float, oo.celltype('D',5)
2312
+ assert_equal :float, oo.celltype('E',5)
2313
+ assert_equal 42, oo.cell('A',5)
2314
+ assert_equal 42, oo.cell('B',5)
2315
+ assert_equal 42, oo.cell('C',5)
2316
+ assert_equal 42, oo.cell('D',5)
2317
+ assert_equal 42, oo.cell('E',5)
2318
+ assert_equal :string, oo.celltype('A',6)
2319
+ assert_equal :string, oo.celltype('B',6)
2320
+ assert_equal :string, oo.celltype('C',6)
2321
+ assert_equal :string, oo.celltype('D',6)
2322
+ assert_equal :string, oo.celltype('E',6)
2323
+ assert_equal "ABC", oo.cell('A',6)
2324
+ assert_equal "ABC", oo.cell('B',6)
2325
+ assert_equal "ABC", oo.cell('C',6)
2326
+ assert_equal "ABC", oo.cell('D',6)
2327
+ assert_equal "ABC", oo.cell('E',6)
2328
+ end # Excelx
1933
2329
  end
1934
2330
 
1935
2331
  def test_multiple_sheets
@@ -2056,17 +2452,73 @@ class TestRoo < Test::Unit::TestCase
2056
2452
  oo.reload
2057
2453
  end
2058
2454
  end
2455
+ if EXCELX
2456
+ oo = Excelx.new(File.join("test","numbers1.xlsx"))
2457
+ 2.times do
2458
+ oo.default_sheet = "Tabelle1"
2459
+ assert_equal 1, oo.cell(1,1)
2460
+ assert_equal 1, oo.cell(1,1,"Tabelle1")
2461
+ assert_equal "I am sheet 2", oo.cell('C',5,"Name of Sheet 2")
2462
+ sheetname = 'Sheet5'
2463
+ assert_equal :date, oo.celltype('A',4,sheetname)
2464
+ assert_equal :date, oo.celltype('B',4,sheetname)
2465
+ assert_equal :date, oo.celltype('C',4,sheetname)
2466
+ assert_equal :date, oo.celltype('D',4,sheetname)
2467
+ assert_equal :date, oo.celltype('E',4,sheetname)
2468
+ assert_equal Date.new(2007,11,21), oo.cell('A',4,sheetname)
2469
+ assert_equal Date.new(2007,11,21), oo.cell('B',4,sheetname)
2470
+ assert_equal Date.new(2007,11,21), oo.cell('C',4,sheetname)
2471
+ assert_equal Date.new(2007,11,21), oo.cell('D',4,sheetname)
2472
+ assert_equal Date.new(2007,11,21), oo.cell('E',4,sheetname)
2473
+ assert_equal :float, oo.celltype('A',5,sheetname)
2474
+ assert_equal :float, oo.celltype('B',5,sheetname)
2475
+ assert_equal :float, oo.celltype('C',5,sheetname)
2476
+ assert_equal :float, oo.celltype('D',5,sheetname)
2477
+ assert_equal :float, oo.celltype('E',5,sheetname)
2478
+ assert_equal 42, oo.cell('A',5,sheetname)
2479
+ assert_equal 42, oo.cell('B',5,sheetname)
2480
+ assert_equal 42, oo.cell('C',5,sheetname)
2481
+ assert_equal 42, oo.cell('D',5,sheetname)
2482
+ assert_equal 42, oo.cell('E',5,sheetname)
2483
+ assert_equal :string, oo.celltype('A',6,sheetname)
2484
+ assert_equal :string, oo.celltype('B',6,sheetname)
2485
+ assert_equal :string, oo.celltype('C',6,sheetname)
2486
+ assert_equal :string, oo.celltype('D',6,sheetname)
2487
+ assert_equal :string, oo.celltype('E',6,sheetname)
2488
+ assert_equal "ABC", oo.cell('A',6,sheetname)
2489
+ assert_equal "ABC", oo.cell('B',6,sheetname)
2490
+ assert_equal "ABC", oo.cell('C',6,sheetname)
2491
+ assert_equal "ABC", oo.cell('D',6,sheetname)
2492
+ assert_equal "ABC", oo.cell('E',6,sheetname)
2493
+ oo.reload
2494
+ end
2495
+ end
2059
2496
  end
2060
2497
 
2061
- def test_bug_empty_sheet
2062
- oo = Openoffice.new(File.join("test","formula.ods"))
2063
- oo.default_sheet = 'Sheet3' # is an empty sheet
2064
- assert_nothing_raised(NoMethodError) {
2065
- oo.to_csv(File.join("/","tmp","emptysheet.csv"))
2066
- }
2067
- assert_equal "", `cat /tmp/emptysheet.csv`
2498
+ def test_bug_empty_sheet_openoffice
2499
+ if OPENOFFICE
2500
+ oo = Openoffice.new(File.join("test","formula.ods"))
2501
+ oo.default_sheet = 'Sheet3' # is an empty sheet
2502
+ assert_nothing_raised(NoMethodError) {
2503
+ oo.to_csv(File.join("/","tmp","emptysheet.csv"))
2504
+ }
2505
+ assert_equal "", `cat /tmp/emptysheet.csv`
2506
+ end
2068
2507
  end
2069
-
2508
+
2509
+ def test_bug_empty_sheet_excelx
2510
+ after Date.new(2008,5,22) do
2511
+ if EXCELX
2512
+ oo = Excelx.new(File.join("test","formula.xlsx"))
2513
+ oo.default_sheet = 'Sheet3' # is an empty sheet
2514
+ assert_nothing_raised(NoMethodError) {
2515
+ oo.to_csv(File.join("/","tmp","emptysheet.csv"))
2516
+ }
2517
+ assert_equal "", `cat /tmp/emptysheet.csv`
2518
+ end
2519
+ end
2520
+ end
2521
+
2070
2522
  def test_find_by_row_huge_document_openoffice
2071
2523
  if LONG_RUN
2072
2524
  if OPENOFFICE
@@ -2106,6 +2558,24 @@ class TestRoo < Test::Unit::TestCase
2106
2558
  end
2107
2559
  end
2108
2560
 
2561
+ def test_find_by_row_huge_document_excelx
2562
+ if LONG_RUN
2563
+ if EXCEL
2564
+ Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
2565
+ oo = Excelx.new(File.join("test","Bibelbund.xlsx"))
2566
+ oo.default_sheet = oo.sheets.first
2567
+ rec = oo.find 20
2568
+ assert rec
2569
+ assert_equal "Brief aus dem Sekretariat", rec[0]
2570
+
2571
+ rec = oo.find 22
2572
+ assert rec
2573
+ assert_equal "Brief aus dem Skretariat. Tagung in Amberg/Opf.",rec[0]
2574
+ end
2575
+ end
2576
+ end
2577
+ end
2578
+
2109
2579
  def test_find_by_row_openoffice
2110
2580
  if OPENOFFICE
2111
2581
  oo = Openoffice.new(File.join("test","numbers1.ods"))
@@ -2140,6 +2610,22 @@ class TestRoo < Test::Unit::TestCase
2140
2610
  end
2141
2611
  end
2142
2612
 
2613
+ def test_find_by_row_excelx
2614
+ if EXCELX
2615
+ oo = Excelx.new(File.join("test","numbers1.xlsx"))
2616
+ oo.default_sheet = oo.sheets.first
2617
+ oo.header_line = nil
2618
+ rec = oo.find 16
2619
+ assert rec
2620
+ # keine Headerlines in diesem Beispiel definiert
2621
+ assert_equal "einundvierzig", rec[0]
2622
+
2623
+ rec = oo.find 15
2624
+ assert rec
2625
+ assert_equal 41,rec[0]
2626
+ end
2627
+ end
2628
+
2143
2629
  def test_find_by_row_google
2144
2630
  if GOOGLE
2145
2631
  oo = Google.new(key_of("numbers1"))
@@ -2331,6 +2817,70 @@ class TestRoo < Test::Unit::TestCase
2331
2817
  end
2332
2818
  end
2333
2819
 
2820
+ def test_find_by_conditions_excelx
2821
+ if LONG_RUN
2822
+ if EXCELX
2823
+ assert_nothing_raised(Timeout::Error) {
2824
+ Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
2825
+ oo = Excelx.new(File.join("test","Bibelbund.xlsx"))
2826
+ oo.default_sheet = oo.sheets.first
2827
+ #-----------------------------------------------------------------
2828
+ zeilen = oo.find(:all, :conditions => {
2829
+ 'TITEL' => 'Brief aus dem Sekretariat'
2830
+ }
2831
+ )
2832
+ assert_equal 2, zeilen.size
2833
+ assert_equal [{"VERFASSER"=>"Almassy, Annelene von",
2834
+ "INTERNET"=>nil,
2835
+ "SEITE"=>316.0,
2836
+ "KENNUNG"=>"Aus dem Bibelbund",
2837
+ "OBJEKT"=>"Bibel+Gem",
2838
+ "PC"=>"#C:\\Bibelbund\\reprint\\BuG1982-3.pdf#",
2839
+ "NUMMER"=>"1982-3",
2840
+ "TITEL"=>"Brief aus dem Sekretariat"},
2841
+ {"VERFASSER"=>"Almassy, Annelene von",
2842
+ "INTERNET"=>nil,
2843
+ "SEITE"=>222.0,
2844
+ "KENNUNG"=>"Aus dem Bibelbund",
2845
+ "OBJEKT"=>"Bibel+Gem",
2846
+ "PC"=>"#C:\\Bibelbund\\reprint\\BuG1983-2.pdf#",
2847
+ "NUMMER"=>"1983-2",
2848
+ "TITEL"=>"Brief aus dem Sekretariat"}] , zeilen
2849
+
2850
+ #----------------------------------------------------------
2851
+ zeilen = oo.find(:all,
2852
+ :conditions => { 'VERFASSER' => 'Almassy, Annelene von' }
2853
+ )
2854
+ assert_equal 13, zeilen.size
2855
+ #----------------------------------------------------------
2856
+ zeilen = oo.find(:all, :conditions => {
2857
+ 'TITEL' => 'Brief aus dem Sekretariat',
2858
+ 'VERFASSER' => 'Almassy, Annelene von',
2859
+ }
2860
+ )
2861
+ assert_equal 2, zeilen.size
2862
+ assert_equal [{"VERFASSER"=>"Almassy, Annelene von",
2863
+ "INTERNET"=>nil,
2864
+ "SEITE"=>316.0,
2865
+ "KENNUNG"=>"Aus dem Bibelbund",
2866
+ "OBJEKT"=>"Bibel+Gem",
2867
+ "PC"=>"#C:\\Bibelbund\\reprint\\BuG1982-3.pdf#",
2868
+ "NUMMER"=>"1982-3",
2869
+ "TITEL"=>"Brief aus dem Sekretariat"},
2870
+ {"VERFASSER"=>"Almassy, Annelene von",
2871
+ "INTERNET"=>nil,
2872
+ "SEITE"=>222.0,
2873
+ "KENNUNG"=>"Aus dem Bibelbund",
2874
+ "OBJEKT"=>"Bibel+Gem",
2875
+ "PC"=>"#C:\\Bibelbund\\reprint\\BuG1983-2.pdf#",
2876
+ "NUMMER"=>"1983-2",
2877
+ "TITEL"=>"Brief aus dem Sekretariat"}] , zeilen
2878
+ end # Timeout
2879
+ } # nothing_raised
2880
+ end
2881
+ end
2882
+ end
2883
+
2334
2884
  def test_find_by_conditions_google
2335
2885
  if LONG_RUN
2336
2886
  if GOOGLE
@@ -2448,6 +2998,18 @@ class TestRoo < Test::Unit::TestCase
2448
2998
  end
2449
2999
  end
2450
3000
 
3001
+ def test_column_excelx
3002
+ 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)]
3003
+ if EXCELX
3004
+ Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
3005
+ oo = Excelx.new(File.join('test','numbers1.xlsx'))
3006
+ oo.default_sheet = oo.sheets.first
3007
+ assert_equal expected, oo.column(1)
3008
+ assert_equal expected, oo.column('a')
3009
+ end
3010
+ end
3011
+ end
3012
+
2451
3013
  def test_column_google
2452
3014
  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)]
2453
3015
  if GOOGLE
@@ -2490,6 +3052,21 @@ class TestRoo < Test::Unit::TestCase
2490
3052
  end
2491
3053
  end
2492
3054
 
3055
+ def test_column_huge_document_excelx
3056
+ if LONG_RUN
3057
+ if EXCELX
3058
+ assert_nothing_raised(Timeout::Error) {
3059
+ Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
3060
+ oo = Excelx.new(File.join('test','Bibelbund.xlsx'))
3061
+ oo.default_sheet = oo.sheets.first
3062
+ assert_equal 3735, oo.column('a').size
3063
+ #assert_equal 499, oo.column('a').size
3064
+ end
3065
+ }
3066
+ end
3067
+ end
3068
+ end
3069
+
2493
3070
  def test_column_huge_document_google
2494
3071
  if LONG_RUN
2495
3072
  if GOOGLE
@@ -2521,6 +3098,7 @@ class TestRoo < Test::Unit::TestCase
2521
3098
  end
2522
3099
 
2523
3100
  def test_simple_spreadsheet_find_by_condition_excel
3101
+ if EXCEL
2524
3102
  oo = Excel.new(File.join("test","simple_spreadsheet.xls"))
2525
3103
  oo.default_sheet = oo.sheets.first
2526
3104
  oo.header_line = 3
@@ -2532,6 +3110,29 @@ class TestRoo < Test::Unit::TestCase
2532
3110
  #cannot be tested because excel cannot return the result of formulas:
2533
3111
  # assert_equal 1.75 , erg[1]['Sum']
2534
3112
  assert_equal "Task 1" , erg[1]['Comment']
3113
+ end
3114
+ end
3115
+
3116
+ def test_simple_spreadsheet_find_by_condition_excelx
3117
+ if EXCELX
3118
+ after Date.new(2008,5,25) do
3119
+ oo = Excelx.new(File.join("test","simple_spreadsheet.xlsx"))
3120
+ oo.default_sheet = oo.sheets.first
3121
+ oo.header_line = 3
3122
+ erg = oo.find(:all, :conditions => {'Comment' => 'Task 1'})
3123
+ p erg
3124
+ #
3125
+ #
3126
+
3127
+ # hier bekomme ich den celltype :time zurueck
3128
+ assert_equal Date.new(2007,05,07), erg[1]['Date']
3129
+ assert_equal 10.75 , erg[1]['Start time']
3130
+ assert_equal 12.50 , erg[1]['End time']
3131
+ assert_equal 0 , erg[1]['Pause']
3132
+ assert_equal 1.75 , erg[1]['Sum']
3133
+ assert_equal "Task 1" , erg[1]['Comment']
3134
+ end
3135
+ end
2535
3136
  end
2536
3137
 
2537
3138
  def test_simple_spreadsheet_find_by_condition_google
@@ -2568,52 +3169,58 @@ class TestRoo < Test::Unit::TestCase
2568
3169
  end
2569
3170
 
2570
3171
  def test_bug_false_borders_with_formulas
2571
- ex = Excel.new(File.join('test','false_encoding.xls'))
2572
- ex.default_sheet = ex.sheets.first
2573
- assert_equal 1, ex.first_row
2574
- assert_equal 3, ex.last_row
2575
- assert_equal 1, ex.first_column
2576
- assert_equal 4, ex.last_column
3172
+ after Date.new(2008,5,30) do
3173
+ #TODO: fehlt in Manifest
3174
+ ex = Excel.new(File.join('test','false_encoding.xls'))
3175
+ ex.default_sheet = ex.sheets.first
3176
+ assert_equal 1, ex.first_row
3177
+ assert_equal 3, ex.last_row
3178
+ assert_equal 1, ex.first_column
3179
+ assert_equal 4, ex.last_column
3180
+ end
2577
3181
  end
2578
3182
 
2579
3183
  def test_fe
2580
- ex = Excel.new(File.join('test','false_encoding.xls'))
2581
- ex.default_sheet = ex.sheets.first
2582
- #DOES NOT WORK IN EXCEL FILES: assert_equal Date.new(2007,11,1), ex.cell('a',1)
2583
- #DOES NOT WORK IN EXCEL FILES: assert_equal true, ex.formula?('a',1)
2584
- #DOES NOT WORK IN EXCEL FILES: assert_equal '=TODAY()', ex.formula('a',1)
3184
+ after Date.new(2008,5,30) do
3185
+ ex = Excel.new(File.join('test','false_encoding.xls'))
3186
+ ex.default_sheet = ex.sheets.first
3187
+ #DOES NOT WORK IN EXCEL FILES: assert_equal Date.new(2007,11,1), ex.cell('a',1)
3188
+ #DOES NOT WORK IN EXCEL FILES: assert_equal true, ex.formula?('a',1)
3189
+ #DOES NOT WORK IN EXCEL FILES: assert_equal '=TODAY()', ex.formula('a',1)
2585
3190
 
2586
- #DOES NOT WORK IN EXCEL FILES: assert_equal Date.new(2008,2,9), ex.cell('B',1)
2587
- #DOES NOT WORK IN EXCEL FILES: assert_equal true, ex.formula?('B',1)
2588
- #DOES NOT WORK IN EXCEL FILES: assert_equal "=A1+100", ex.formula('B',1)
3191
+ #DOES NOT WORK IN EXCEL FILES: assert_equal Date.new(2008,2,9), ex.cell('B',1)
3192
+ #DOES NOT WORK IN EXCEL FILES: assert_equal true, ex.formula?('B',1)
3193
+ #DOES NOT WORK IN EXCEL FILES: assert_equal "=A1+100", ex.formula('B',1)
2589
3194
 
2590
- #DOES NOT WORK IN EXCEL FILES: assert_equal Date.new(2008,2,9), ex.cell('C',1)
2591
- #DOES NOT WORK IN EXCEL FILES: assert_equal true, ex.formula?('C',1)
2592
- #DOES NOT WORK IN EXCEL FILES: assert_equal "=C1", ex.formula('C',1)
3195
+ #DOES NOT WORK IN EXCEL FILES: assert_equal Date.new(2008,2,9), ex.cell('C',1)
3196
+ #DOES NOT WORK IN EXCEL FILES: assert_equal true, ex.formula?('C',1)
3197
+ #DOES NOT WORK IN EXCEL FILES: assert_equal "=C1", ex.formula('C',1)
2593
3198
 
2594
- assert_equal 'H1', ex.cell('A',2)
2595
- assert_equal 'H2', ex.cell('B',2)
2596
- assert_equal 'H3', ex.cell('C',2)
2597
- assert_equal 'H4', ex.cell('D',2)
2598
- assert_equal 'R1', ex.cell('A',3)
2599
- assert_equal 'R2', ex.cell('B',3)
2600
- assert_equal 'R3', ex.cell('C',3)
2601
- assert_equal 'R4', ex.cell('D',3)
3199
+ assert_equal 'H1', ex.cell('A',2)
3200
+ assert_equal 'H2', ex.cell('B',2)
3201
+ assert_equal 'H3', ex.cell('C',2)
3202
+ assert_equal 'H4', ex.cell('D',2)
3203
+ assert_equal 'R1', ex.cell('A',3)
3204
+ assert_equal 'R2', ex.cell('B',3)
3205
+ assert_equal 'R3', ex.cell('C',3)
3206
+ assert_equal 'R4', ex.cell('D',3)
3207
+ end
2602
3208
  end
2603
3209
 
2604
3210
  def test_excel_does_not_support_formulas
2605
- ex = Excel.new(File.join('test','false_encoding.xls'))
2606
- ex.default_sheet = ex.sheets.first
2607
- assert_raise(RuntimeError) {
2608
- void = ex.formula('a',1)
2609
- }
2610
- assert_raise(RuntimeError) {
2611
- void = ex.formula?('a',1)
2612
- }
2613
- assert_raise(RuntimeError) {
2614
- void = ex.formulas(ex.sheets.first)
2615
- }
2616
-
3211
+ if EXCEL
3212
+ ex = Excel.new(File.join('test','false_encoding.xls'))
3213
+ ex.default_sheet = ex.sheets.first
3214
+ assert_raise(RuntimeError) {
3215
+ void = ex.formula('a',1)
3216
+ }
3217
+ assert_raise(RuntimeError) {
3218
+ void = ex.formula?('a',1)
3219
+ }
3220
+ assert_raise(RuntimeError) {
3221
+ void = ex.formulas(ex.sheets.first)
3222
+ }
3223
+ end
2617
3224
  end
2618
3225
 
2619
3226
  def test_info
@@ -2657,6 +3264,12 @@ class TestRoo < Test::Unit::TestCase
2657
3264
  oo = Excel.new(File.join("test","numbers1.xls"))
2658
3265
  assert_equal expected, oo.info
2659
3266
  end
3267
+ if EXCELX
3268
+ ext = ".xlsx"
3269
+ expected = sprintf(expected_templ,ext)
3270
+ oo = Excelx.new(File.join("test","numbers1.xlsx"))
3271
+ assert_equal expected, oo.info
3272
+ end
2660
3273
  if GOOGLE
2661
3274
  ext = ""
2662
3275
  expected = sprintf(expected_templ,ext)
@@ -2706,13 +3319,16 @@ class TestRoo < Test::Unit::TestCase
2706
3319
  oo = Excel.new(File.join('testnichtvorhanden','Bibelbund.xls'))
2707
3320
  }
2708
3321
  end
3322
+ if EXCELX
3323
+ assert_raise(IOError) {
3324
+ oo = Excelx.new(File.join('testnichtvorhanden','Bibelbund.xlsx'))
3325
+ }
3326
+ end
2709
3327
  if GOOGLE
2710
- after Date.new(2008,4,1) do
2711
- assert_raise(IOError) {
2712
- # oo = Google.new(key_of('testnichtvorhanden'+'Bibelbund.ods'))
2713
- oo = Google.new('testnichtvorhanden')
2714
- }
2715
- end
3328
+ assert_raise(IOError) {
3329
+ # oo = Google.new(key_of('testnichtvorhanden'+'Bibelbund.ods'))
3330
+ oo = Google.new('testnichtvorhanden')
3331
+ }
2716
3332
  end
2717
3333
  end
2718
3334
 
@@ -2829,6 +3445,32 @@ Sheet 3:
2829
3445
  assert_nil oo.last_column
2830
3446
  end
2831
3447
 
3448
+ def test_bug_bbu_excelx
3449
+ if EXCELX
3450
+ oo = Excelx.new(File.join('test','bbu.xlsx'))
3451
+ assert_nothing_raised() {
3452
+ assert_equal "File: bbu.xlsx
3453
+ Number of sheets: 3
3454
+ Sheets: 2007_12, Tabelle2, Tabelle3
3455
+ Sheet 1:
3456
+ First row: 1
3457
+ Last row: 4
3458
+ First column: A
3459
+ Last column: F
3460
+ Sheet 2:
3461
+ - empty -
3462
+ Sheet 3:
3463
+ - empty -", oo.info
3464
+ }
3465
+
3466
+ oo.default_sheet = oo.sheets[1] # empty sheet
3467
+ assert_nil oo.first_row
3468
+ assert_nil oo.last_row
3469
+ assert_nil oo.first_column
3470
+ assert_nil oo.last_column
3471
+ end
3472
+ end
3473
+
2832
3474
  if false
2833
3475
  # there is no google spreadsheet for this test
2834
3476
  def test_bug_bbu_google
@@ -2891,6 +3533,20 @@ Sheet 3:
2891
3533
  end
2892
3534
  end
2893
3535
 
3536
+ def test_bug_time_nil_excelx
3537
+ if EXCELX
3538
+ oo = Excelx.new(File.join("test","time-test.xlsx"))
3539
+ oo.default_sheet = oo.sheets.first
3540
+ assert_equal 12*3600+13*60+14, oo.cell('B',1) # 12:13:14 (secs since midnight)
3541
+ assert_equal :time, oo.celltype('B',1)
3542
+ assert_equal 15*3600+16*60, oo.cell('C',1) # 15:16 (secs since midnight)
3543
+ assert_equal :time, oo.celltype('C',1)
3544
+
3545
+ assert_equal 23*3600, oo.cell('D',1) # 23:00 (secs since midnight)
3546
+ assert_equal :time, oo.celltype('D',1)
3547
+ end
3548
+ end
3549
+
2894
3550
  def test_bug_time_nil_google
2895
3551
  if GOOGLE
2896
3552
  oo = Google.new(key_of("time-test"))
@@ -2918,7 +3574,7 @@ Sheet 3:
2918
3574
 
2919
3575
  def test_date_time_to_csv_excel
2920
3576
  if EXCEL
2921
- after Date.new(2008,4,30) do
3577
+ after Date.new(2008,5,30) do
2922
3578
  #ueberfluessige leere Zeilen werden am Ende noch angehaengt
2923
3579
  # last_row fehlerhaft?
2924
3580
  File.delete_if_exist("/tmp/time-test.csv")
@@ -2931,6 +3587,21 @@ Sheet 3:
2931
3587
  end # EXCEL
2932
3588
  end
2933
3589
 
3590
+ def test_date_time_to_csv_excelx
3591
+ if EXCELX
3592
+ after Date.new(2008,5,3) do
3593
+ #ueberfluessige leere Zeilen werden am Ende noch angehaengt
3594
+ # last_row fehlerhaft?
3595
+ File.delete_if_exist("/tmp/time-test.csv")
3596
+ oo = Excelx.new(File.join("test","time-test.xlsx"))
3597
+ oo.default_sheet = oo.sheets.first
3598
+ assert oo.to_csv("/tmp/time-test.csv")
3599
+ assert File.exists?("/tmp/time-test.csv")
3600
+ assert_equal "", `diff test/time-test.csv /tmp/time-test.csv`
3601
+ end
3602
+ end # EXCELX
3603
+ end
3604
+
2934
3605
  def test_date_time_to_csv_google
2935
3606
  if GOOGLE
2936
3607
  File.delete_if_exist("/tmp/time-test.csv")
@@ -2962,6 +3633,16 @@ Sheet 3:
2962
3633
  end
2963
3634
  end
2964
3635
 
3636
+ def test_date_time_yaml_excelx
3637
+ if EXCELX
3638
+ expected =
3639
+ "--- \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"
3640
+ oo = Excelx.new(File.join("test","time-test.xlsx"))
3641
+ oo.default_sheet = oo.sheets.first
3642
+ assert_equal expected, oo.to_yaml
3643
+ end
3644
+ end
3645
+
2965
3646
  def test_date_time_yaml_google
2966
3647
  if GOOGLE
2967
3648
  expected =
@@ -2991,6 +3672,18 @@ Sheet 3:
2991
3672
  assert_equal [], a
2992
3673
  end
2993
3674
  end
3675
+
3676
+ def test_no_remaining_tmp_files_excelx
3677
+ if EXCELX
3678
+ assert_raise(Zip::ZipError) { #TODO: besseres Fehlerkriterium bei
3679
+
3680
+ oo = Excelx.new(File.join("test","no_spreadsheet_file.txt"))
3681
+
3682
+ }
3683
+ a=Dir.glob("oo_*")
3684
+ assert_equal [], a
3685
+ end
3686
+ end
2994
3687
 
2995
3688
  def test_no_remaining_tmp_files_google
2996
3689
  if GOOGLE
@@ -3004,101 +3697,395 @@ Sheet 3:
3004
3697
 
3005
3698
  def emit_cell(row,col,type,value)
3006
3699
  " <cell "+
3007
- "row=\"#{row}\" "+
3008
3700
  "type=\"#{type}\" "+
3701
+ "row=\"#{row}\" "+
3009
3702
  "column=\"#{col}\""+
3010
3703
  ">#{value}</cell>\n"
3011
3704
  end
3012
3705
 
3013
3706
  def test_to_xml_openoffice
3014
- if OPENOFFICE
3015
- oo = Openoffice.new(File.join('test','numbers1.ods'))
3016
- expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"+
3017
- "<sheet name=\"Tabelle1\">\n"+
3018
- emit_cell(1,1,"float","1.0")+
3019
- emit_cell(1,2,'float','2.0')+
3020
- emit_cell(1,3,'float','3.0')+
3021
- emit_cell(1,4,'float','4.0')+
3022
- emit_cell(1,5,'formula','10.0')+
3023
- emit_cell(2,1,'float','5.0')+
3024
- emit_cell(2,2,'float','6.0')+
3025
- emit_cell(2,3,'float','7.0')+
3026
- emit_cell(2,4,'float','8.0')+
3027
- emit_cell(2,5,'float','9.0')+
3028
- emit_cell(2,6,'string','test')+
3029
- emit_cell(2,7,'float','11.0')+
3030
- emit_cell(4, 1, "float", "10.0")+
3031
- emit_cell(4, 2, "float", "11.0")+
3032
- emit_cell(4, 3, "float", "12.0")+
3033
- emit_cell(4, 4, "float", "13.0")+
3034
- emit_cell(4, 5, "float", "14.0")+
3035
- emit_cell(5, 1, "date", "1961-11-21")+
3036
- emit_cell(6, 1, "string", "tata")+
3037
- emit_cell(8, 3, "string", "thisisc8")+
3038
- emit_cell(9,4, "string", "thisisd9")+
3039
- emit_cell(11, 1, "string", "thisisa11")+
3040
- emit_cell(12, 1, "float", "41.0")+
3041
- emit_cell(12, 2, "float", "42.0")+
3042
- emit_cell(12, 3, "float", "43.0")+
3043
- emit_cell(12, 4, "float", "44.0")+
3044
- emit_cell(12, 5, "float", "45.0")+
3045
- emit_cell(15, 1, "float", "41.0")+
3046
- emit_cell(15, 2, "float", "42.0")+
3047
- emit_cell(15, 3, "float", "43.0")+
3048
- emit_cell(15, 4, "float", "44.0")+
3049
- emit_cell(15, 5, "float", "45.0")+
3050
- emit_cell(16, 1, "string", "einundvierzig")+
3051
- emit_cell(16, 2, "string", "zweiundvierzig")+
3052
- emit_cell(16, 3, "string", "dreiundvierzig")+
3053
- emit_cell(16, 4, "string", "vierundvierzig")+
3054
- emit_cell(16, 5, "string", "fuenfundvierzig")+
3055
- emit_cell(18, 1, "date", "2007-05-31")+
3056
- emit_cell(18, 2, "string", "dies hier als Date-Objekt")+
3057
- "</sheet>\n"+
3058
- "<sheet name=\"Name of Sheet 2\">\n"+
3059
- emit_cell(5, 3, "string", "I am sheet 2")+
3060
- emit_cell(7, 2, "float", "3.0")+
3061
- emit_cell(10, 5, "float", "7.0")+
3062
- emit_cell(14, 4, "float", "9.0")+
3063
- "</sheet>\n"+
3064
- "<sheet name=\"Sheet3\">\n"+
3065
- emit_cell(1, 1, "string", "ganz weit rechts geht&#8217;s weiter")+
3066
- emit_cell(1, GenericSpreadsheet.letter_to_number('AA'), "string", "i am AA")+
3067
- emit_cell(1, GenericSpreadsheet.letter_to_number('AB'), "string", "i am AB")+
3068
- emit_cell(1, GenericSpreadsheet.letter_to_number('BA'), "string", "i am BA")+
3069
- "</sheet>\n"+
3070
- "<sheet name=\"Sheet4\">\n"+
3071
- emit_cell(1, 1, "date", "2007-06-16")+
3072
- emit_cell(1, 2, "float", "10.0")+
3073
- emit_cell(1, 3, "float", "10.0")+
3074
- emit_cell(1, 4, "float", "10.0")+
3075
- emit_cell(1, 5, "float", "10.0")+
3076
- "</sheet>\n"+
3077
- "<sheet name=\"Sheet5\">\n"+
3078
- emit_cell(1, 1, "float", "1.0")+
3079
- emit_cell(1, 2, "float", "5.0")+
3080
- emit_cell(1, 3, "float", "5.0")+
3081
- emit_cell(2, 1, "float", "2.0")+
3082
- emit_cell(3, 1, "float", "3.0")+
3083
- emit_cell(4, 1, "date", "2007-11-21")+
3084
- emit_cell(4, 2, "date", "2007-11-21")+
3085
- emit_cell(4, 3, "date", "2007-11-21")+
3086
- emit_cell(4, 4, "date", "2007-11-21")+
3087
- emit_cell(4, 5, "date", "2007-11-21")+
3088
- emit_cell(5, 1, "float", "42.0")+
3089
- emit_cell(5, 2, "float", "42.0")+
3090
- emit_cell(5, 3, "float", "42.0")+
3091
- emit_cell(5, 4, "float", "42.0")+
3092
- emit_cell(5, 5, "float", "42.0")+
3093
- emit_cell(6, 1, "string", "ABC")+
3094
- emit_cell(6, 2, "string", "ABC")+
3095
- emit_cell(6, 3, "string", "ABC")+
3096
- emit_cell(6, 4, "string", "ABC")+
3097
- emit_cell(6, 5, "string", "ABC")+
3098
- "</sheet>\n"+
3099
- ""
3100
- # oo.default_sheet = oo.sheets.first
3101
- assert_equal expected, oo.to_xml
3707
+ after Date.new(2008,6,1) do
3708
+ if OPENOFFICE
3709
+ oo = Openoffice.new(File.join('test','numbers1.ods'))
3710
+ expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"+
3711
+ "<sheet name=\"Tabelle1\">\n"+
3712
+ emit_cell(1,1,"float","1.0")+
3713
+ emit_cell(1,2,'float','2.0')+
3714
+ emit_cell(1,3,'float','3.0')+
3715
+ emit_cell(1,4,'float','4.0')+
3716
+ emit_cell(1,5,'formula','10.0')+
3717
+ emit_cell(2,1,'float','5.0')+
3718
+ emit_cell(2,2,'float','6.0')+
3719
+ emit_cell(2,3,'float','7.0')+
3720
+ emit_cell(2,4,'float','8.0')+
3721
+ emit_cell(2,5,'float','9.0')+
3722
+ emit_cell(2,6,'string','test')+
3723
+ emit_cell(2,7,'float','11.0')+
3724
+ emit_cell(4, 1, "float", "10.0")+
3725
+ emit_cell(4, 2, "float", "11.0")+
3726
+ emit_cell(4, 3, "float", "12.0")+
3727
+ emit_cell(4, 4, "float", "13.0")+
3728
+ emit_cell(4, 5, "float", "14.0")+
3729
+ emit_cell(5, 1, "date", "1961-11-21")+
3730
+ emit_cell(6, 1, "string", "tata")+
3731
+ emit_cell(8, 3, "string", "thisisc8")+
3732
+ emit_cell(9,4, "string", "thisisd9")+
3733
+ emit_cell(11, 1, "string", "thisisa11")+
3734
+ emit_cell(12, 1, "float", "41.0")+
3735
+ emit_cell(12, 2, "float", "42.0")+
3736
+ emit_cell(12, 3, "float", "43.0")+
3737
+ emit_cell(12, 4, "float", "44.0")+
3738
+ emit_cell(12, 5, "float", "45.0")+
3739
+ emit_cell(15, 1, "float", "41.0")+
3740
+ emit_cell(15, 2, "float", "42.0")+
3741
+ emit_cell(15, 3, "float", "43.0")+
3742
+ emit_cell(15, 4, "float", "44.0")+
3743
+ emit_cell(15, 5, "float", "45.0")+
3744
+ emit_cell(16, 1, "string", "einundvierzig")+
3745
+ emit_cell(16, 2, "string", "zweiundvierzig")+
3746
+ emit_cell(16, 3, "string", "dreiundvierzig")+
3747
+ emit_cell(16, 4, "string", "vierundvierzig")+
3748
+ emit_cell(16, 5, "string", "fuenfundvierzig")+
3749
+ emit_cell(18, 1, "date", "2007-05-31")+
3750
+ emit_cell(18, 2, "string", "dies hier als Date-Objekt")+
3751
+ "</sheet>\n"+
3752
+ "<sheet name=\"Name of Sheet 2\">\n"+
3753
+ emit_cell(5, 3, "string", "I am sheet 2")+
3754
+ emit_cell(7, 2, "float", "3.0")+
3755
+ emit_cell(10, 5, "float", "7.0")+
3756
+ emit_cell(14, 4, "float", "9.0")+
3757
+ "</sheet>\n"+
3758
+ "<sheet name=\"Sheet3\">\n"+
3759
+ emit_cell(1, 1, "string", "ganz weit rechts geht&#8217;s weiter")+
3760
+ emit_cell(1, GenericSpreadsheet.letter_to_number('AA'), "string", "i am AA")+
3761
+ emit_cell(1, GenericSpreadsheet.letter_to_number('AB'), "string", "i am AB")+
3762
+ emit_cell(1, GenericSpreadsheet.letter_to_number('BA'), "string", "i am BA")+
3763
+ "</sheet>\n"+
3764
+ "<sheet name=\"Sheet4\">\n"+
3765
+ emit_cell(1, 1, "date", "2007-06-16")+
3766
+ emit_cell(1, 2, "float", "10.0")+
3767
+ emit_cell(1, 3, "float", "10.0")+
3768
+ emit_cell(1, 4, "float", "10.0")+
3769
+ emit_cell(1, 5, "float", "10.0")+
3770
+ "</sheet>\n"+
3771
+ "<sheet name=\"Sheet5\">\n"+
3772
+ emit_cell(1, 1, "float", "1.0")+
3773
+ emit_cell(1, 2, "float", "5.0")+
3774
+ emit_cell(1, 3, "float", "5.0")+
3775
+ emit_cell(2, 1, "float", "2.0")+
3776
+ emit_cell(3, 1, "float", "3.0")+
3777
+ emit_cell(4, 1, "date", "2007-11-21")+
3778
+ emit_cell(4, 2, "date", "2007-11-21")+
3779
+ emit_cell(4, 3, "date", "2007-11-21")+
3780
+ emit_cell(4, 4, "date", "2007-11-21")+
3781
+ emit_cell(4, 5, "date", "2007-11-21")+
3782
+ emit_cell(5, 1, "float", "42.0")+
3783
+ emit_cell(5, 2, "float", "42.0")+
3784
+ emit_cell(5, 3, "float", "42.0")+
3785
+ emit_cell(5, 4, "float", "42.0")+
3786
+ emit_cell(5, 5, "float", "42.0")+
3787
+ emit_cell(6, 1, "string", "ABC")+
3788
+ emit_cell(6, 2, "string", "ABC")+
3789
+ emit_cell(6, 3, "string", "ABC")+
3790
+ emit_cell(6, 4, "string", "ABC")+
3791
+ emit_cell(6, 5, "string", "ABC")+
3792
+ "</sheet>\n"+
3793
+ ""
3794
+ # oo.default_sheet = oo.sheets.first
3795
+ assert_equal expected, oo.to_xml
3796
+ end
3797
+ end
3798
+ end
3799
+
3800
+ def test_to_xml_excel
3801
+ after Date.new(2008,6,1) do
3802
+ if EXCEL
3803
+ oo = Excel.new(File.join('test','numbers1.xls'))
3804
+ expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"+
3805
+ "<sheet name=\"Tabelle1\">\n"+
3806
+ emit_cell(1,1,"float","1.0")+
3807
+ emit_cell(1,2,'float','2.0')+
3808
+ emit_cell(1,3,'float','3.0')+
3809
+ emit_cell(1,4,'float','4.0')+
3810
+ emit_cell(1,5,'formula','10.0')+
3811
+ emit_cell(2,1,'float','5.0')+
3812
+ emit_cell(2,2,'float','6.0')+
3813
+ emit_cell(2,3,'float','7.0')+
3814
+ emit_cell(2,4,'float','8.0')+
3815
+ emit_cell(2,5,'float','9.0')+
3816
+ emit_cell(2,6,'string','test')+
3817
+ emit_cell(2,7,'float','11.0')+
3818
+ emit_cell(4, 1, "float", "10.0")+
3819
+ emit_cell(4, 2, "float", "11.0")+
3820
+ emit_cell(4, 3, "float", "12.0")+
3821
+ emit_cell(4, 4, "float", "13.0")+
3822
+ emit_cell(4, 5, "float", "14.0")+
3823
+ emit_cell(5, 1, "date", "1961-11-21")+
3824
+ emit_cell(6, 1, "string", "tata")+
3825
+ emit_cell(8, 3, "string", "thisisc8")+
3826
+ emit_cell(9,4, "string", "thisisd9")+
3827
+ emit_cell(11, 1, "string", "thisisa11")+
3828
+ emit_cell(12, 1, "float", "41.0")+
3829
+ emit_cell(12, 2, "float", "42.0")+
3830
+ emit_cell(12, 3, "float", "43.0")+
3831
+ emit_cell(12, 4, "float", "44.0")+
3832
+ emit_cell(12, 5, "float", "45.0")+
3833
+ emit_cell(15, 1, "float", "41.0")+
3834
+ emit_cell(15, 2, "float", "42.0")+
3835
+ emit_cell(15, 3, "float", "43.0")+
3836
+ emit_cell(15, 4, "float", "44.0")+
3837
+ emit_cell(15, 5, "float", "45.0")+
3838
+ emit_cell(16, 1, "string", "einundvierzig")+
3839
+ emit_cell(16, 2, "string", "zweiundvierzig")+
3840
+ emit_cell(16, 3, "string", "dreiundvierzig")+
3841
+ emit_cell(16, 4, "string", "vierundvierzig")+
3842
+ emit_cell(16, 5, "string", "fuenfundvierzig")+
3843
+ emit_cell(18, 1, "date", "2007-05-31")+
3844
+ emit_cell(18, 2, "string", "dies hier als Date-Objekt")+
3845
+ "</sheet>\n"+
3846
+ "<sheet name=\"Name of Sheet 2\">\n"+
3847
+ emit_cell(5, 3, "string", "I am sheet 2")+
3848
+ emit_cell(7, 2, "float", "3.0")+
3849
+ emit_cell(10, 5, "float", "7.0")+
3850
+ emit_cell(14, 4, "float", "9.0")+
3851
+ "</sheet>\n"+
3852
+ "<sheet name=\"Sheet3\">\n"+
3853
+ emit_cell(1, 1, "string", "ganz weit rechts geht&#8217;s weiter")+
3854
+ emit_cell(1, GenericSpreadsheet.letter_to_number('AA'), "string", "i am AA")+
3855
+ emit_cell(1, GenericSpreadsheet.letter_to_number('AB'), "string", "i am AB")+
3856
+ emit_cell(1, GenericSpreadsheet.letter_to_number('BA'), "string", "i am BA")+
3857
+ "</sheet>\n"+
3858
+ "<sheet name=\"Sheet4\">\n"+
3859
+ emit_cell(1, 1, "date", "2007-06-16")+
3860
+ emit_cell(1, 2, "float", "10.0")+
3861
+ emit_cell(1, 3, "float", "10.0")+
3862
+ emit_cell(1, 4, "float", "10.0")+
3863
+ emit_cell(1, 5, "float", "10.0")+
3864
+ "</sheet>\n"+
3865
+ "<sheet name=\"Sheet5\">\n"+
3866
+ emit_cell(1, 1, "float", "1.0")+
3867
+ emit_cell(1, 2, "float", "5.0")+
3868
+ emit_cell(1, 3, "float", "5.0")+
3869
+ emit_cell(2, 1, "float", "2.0")+
3870
+ emit_cell(3, 1, "float", "3.0")+
3871
+ emit_cell(4, 1, "date", "2007-11-21")+
3872
+ emit_cell(4, 2, "date", "2007-11-21")+
3873
+ emit_cell(4, 3, "date", "2007-11-21")+
3874
+ emit_cell(4, 4, "date", "2007-11-21")+
3875
+ emit_cell(4, 5, "date", "2007-11-21")+
3876
+ emit_cell(5, 1, "float", "42.0")+
3877
+ emit_cell(5, 2, "float", "42.0")+
3878
+ emit_cell(5, 3, "float", "42.0")+
3879
+ emit_cell(5, 4, "float", "42.0")+
3880
+ emit_cell(5, 5, "float", "42.0")+
3881
+ emit_cell(6, 1, "string", "ABC")+
3882
+ emit_cell(6, 2, "string", "ABC")+
3883
+ emit_cell(6, 3, "string", "ABC")+
3884
+ emit_cell(6, 4, "string", "ABC")+
3885
+ emit_cell(6, 5, "string", "ABC")+
3886
+ "</sheet>\n"+
3887
+ ""
3888
+ # oo.default_sheet = oo.sheets.first
3889
+ assert_equal expected, oo.to_xml
3890
+ end
3891
+ end
3892
+ end
3893
+
3894
+ def test_to_xml_excelx
3895
+ after Date.new(2008,6,1) do
3896
+ if EXCELX
3897
+ oo = Excelx.new(File.join('test','numbers1.xlsx'))
3898
+ expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"+
3899
+ "<sheet name=\"Tabelle1\">\n"+
3900
+ emit_cell(1,1,"float","1.0")+
3901
+ emit_cell(1,2,'float','2.0')+
3902
+ emit_cell(1,3,'float','3.0')+
3903
+ emit_cell(1,4,'float','4.0')+
3904
+ emit_cell(1,5,'formula','10.0')+
3905
+ emit_cell(2,1,'float','5.0')+
3906
+ emit_cell(2,2,'float','6.0')+
3907
+ emit_cell(2,3,'float','7.0')+
3908
+ emit_cell(2,4,'float','8.0')+
3909
+ emit_cell(2,5,'float','9.0')+
3910
+ emit_cell(2,6,'string','test')+
3911
+ emit_cell(2,7,'float','11.0')+
3912
+ emit_cell(4, 1, "float", "10.0")+
3913
+ emit_cell(4, 2, "float", "11.0")+
3914
+ emit_cell(4, 3, "float", "12.0")+
3915
+ emit_cell(4, 4, "float", "13.0")+
3916
+ emit_cell(4, 5, "float", "14.0")+
3917
+ emit_cell(5, 1, "date", "1961-11-21")+
3918
+ emit_cell(6, 1, "string", "tata")+
3919
+ emit_cell(8, 3, "string", "thisisc8")+
3920
+ emit_cell(9,4, "string", "thisisd9")+
3921
+ emit_cell(11, 1, "string", "thisisa11")+
3922
+ emit_cell(12, 1, "float", "41.0")+
3923
+ emit_cell(12, 2, "float", "42.0")+
3924
+ emit_cell(12, 3, "float", "43.0")+
3925
+ emit_cell(12, 4, "float", "44.0")+
3926
+ emit_cell(12, 5, "float", "45.0")+
3927
+ emit_cell(15, 1, "float", "41.0")+
3928
+ emit_cell(15, 2, "float", "42.0")+
3929
+ emit_cell(15, 3, "float", "43.0")+
3930
+ emit_cell(15, 4, "float", "44.0")+
3931
+ emit_cell(15, 5, "float", "45.0")+
3932
+ emit_cell(16, 1, "string", "einundvierzig")+
3933
+ emit_cell(16, 2, "string", "zweiundvierzig")+
3934
+ emit_cell(16, 3, "string", "dreiundvierzig")+
3935
+ emit_cell(16, 4, "string", "vierundvierzig")+
3936
+ emit_cell(16, 5, "string", "fuenfundvierzig")+
3937
+ emit_cell(18, 1, "date", "2007-05-31")+
3938
+ emit_cell(18, 2, "string", "dies hier als Date-Objekt")+
3939
+ "</sheet>\n"+
3940
+ "<sheet name=\"Name of Sheet 2\">\n"+
3941
+ emit_cell(5, 3, "string", "I am sheet 2")+
3942
+ emit_cell(7, 2, "float", "3.0")+
3943
+ emit_cell(10, 5, "float", "7.0")+
3944
+ emit_cell(14, 4, "float", "9.0")+
3945
+ "</sheet>\n"+
3946
+ "<sheet name=\"Sheet3\">\n"+
3947
+ emit_cell(1, 1, "string", "ganz weit rechts geht&#8217;s weiter")+
3948
+ emit_cell(1, GenericSpreadsheet.letter_to_number('AA'), "string", "i am AA")+
3949
+ emit_cell(1, GenericSpreadsheet.letter_to_number('AB'), "string", "i am AB")+
3950
+ emit_cell(1, GenericSpreadsheet.letter_to_number('BA'), "string", "i am BA")+
3951
+ "</sheet>\n"+
3952
+ "<sheet name=\"Sheet4\">\n"+
3953
+ emit_cell(1, 1, "date", "2007-06-16")+
3954
+ emit_cell(1, 2, "float", "10.0")+
3955
+ emit_cell(1, 3, "float", "10.0")+
3956
+ emit_cell(1, 4, "float", "10.0")+
3957
+ emit_cell(1, 5, "float", "10.0")+
3958
+ "</sheet>\n"+
3959
+ "<sheet name=\"Sheet5\">\n"+
3960
+ emit_cell(1, 1, "float", "1.0")+
3961
+ emit_cell(1, 2, "float", "5.0")+
3962
+ emit_cell(1, 3, "float", "5.0")+
3963
+ emit_cell(2, 1, "float", "2.0")+
3964
+ emit_cell(3, 1, "float", "3.0")+
3965
+ emit_cell(4, 1, "date", "2007-11-21")+
3966
+ emit_cell(4, 2, "date", "2007-11-21")+
3967
+ emit_cell(4, 3, "date", "2007-11-21")+
3968
+ emit_cell(4, 4, "date", "2007-11-21")+
3969
+ emit_cell(4, 5, "date", "2007-11-21")+
3970
+ emit_cell(5, 1, "float", "42.0")+
3971
+ emit_cell(5, 2, "float", "42.0")+
3972
+ emit_cell(5, 3, "float", "42.0")+
3973
+ emit_cell(5, 4, "float", "42.0")+
3974
+ emit_cell(5, 5, "float", "42.0")+
3975
+ emit_cell(6, 1, "string", "ABC")+
3976
+ emit_cell(6, 2, "string", "ABC")+
3977
+ emit_cell(6, 3, "string", "ABC")+
3978
+ emit_cell(6, 4, "string", "ABC")+
3979
+ emit_cell(6, 5, "string", "ABC")+
3980
+ "</sheet>\n"+
3981
+ ""
3982
+ # oo.default_sheet = oo.sheets.first
3983
+ assert_equal expected, oo.to_xml
3984
+ end
3102
3985
  end
3103
3986
  end
3987
+
3988
+ def test_to_xml_google
3989
+ after Date.new(2008,6,1) do
3990
+ if GOOGLE
3991
+ oo = Google.new(key_of(File.join('test','numbers1.xlsx')))
3992
+ expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"+
3993
+ "<sheet name=\"Tabelle1\">\n"+
3994
+ emit_cell(1,1,"float","1.0")+
3995
+ emit_cell(1,2,'float','2.0')+
3996
+ emit_cell(1,3,'float','3.0')+
3997
+ emit_cell(1,4,'float','4.0')+
3998
+ emit_cell(1,5,'formula','10.0')+
3999
+ emit_cell(2,1,'float','5.0')+
4000
+ emit_cell(2,2,'float','6.0')+
4001
+ emit_cell(2,3,'float','7.0')+
4002
+ emit_cell(2,4,'float','8.0')+
4003
+ emit_cell(2,5,'float','9.0')+
4004
+ emit_cell(2,6,'string','test')+
4005
+ emit_cell(2,7,'float','11.0')+
4006
+ emit_cell(4, 1, "float", "10.0")+
4007
+ emit_cell(4, 2, "float", "11.0")+
4008
+ emit_cell(4, 3, "float", "12.0")+
4009
+ emit_cell(4, 4, "float", "13.0")+
4010
+ emit_cell(4, 5, "float", "14.0")+
4011
+ emit_cell(5, 1, "date", "1961-11-21")+
4012
+ emit_cell(6, 1, "string", "tata")+
4013
+ emit_cell(8, 3, "string", "thisisc8")+
4014
+ emit_cell(9,4, "string", "thisisd9")+
4015
+ emit_cell(11, 1, "string", "thisisa11")+
4016
+ emit_cell(12, 1, "float", "41.0")+
4017
+ emit_cell(12, 2, "float", "42.0")+
4018
+ emit_cell(12, 3, "float", "43.0")+
4019
+ emit_cell(12, 4, "float", "44.0")+
4020
+ emit_cell(12, 5, "float", "45.0")+
4021
+ emit_cell(15, 1, "float", "41.0")+
4022
+ emit_cell(15, 2, "float", "42.0")+
4023
+ emit_cell(15, 3, "float", "43.0")+
4024
+ emit_cell(15, 4, "float", "44.0")+
4025
+ emit_cell(15, 5, "float", "45.0")+
4026
+ emit_cell(16, 1, "string", "einundvierzig")+
4027
+ emit_cell(16, 2, "string", "zweiundvierzig")+
4028
+ emit_cell(16, 3, "string", "dreiundvierzig")+
4029
+ emit_cell(16, 4, "string", "vierundvierzig")+
4030
+ emit_cell(16, 5, "string", "fuenfundvierzig")+
4031
+ emit_cell(18, 1, "date", "2007-05-31")+
4032
+ emit_cell(18, 2, "string", "dies hier als Date-Objekt")+
4033
+ "</sheet>\n"+
4034
+ "<sheet name=\"Name of Sheet 2\">\n"+
4035
+ emit_cell(5, 3, "string", "I am sheet 2")+
4036
+ emit_cell(7, 2, "float", "3.0")+
4037
+ emit_cell(10, 5, "float", "7.0")+
4038
+ emit_cell(14, 4, "float", "9.0")+
4039
+ "</sheet>\n"+
4040
+ "<sheet name=\"Sheet3\">\n"+
4041
+ emit_cell(1, 1, "string", "ganz weit rechts geht&#8217;s weiter")+
4042
+ emit_cell(1, GenericSpreadsheet.letter_to_number('AA'), "string", "i am AA")+
4043
+ emit_cell(1, GenericSpreadsheet.letter_to_number('AB'), "string", "i am AB")+
4044
+ emit_cell(1, GenericSpreadsheet.letter_to_number('BA'), "string", "i am BA")+
4045
+ "</sheet>\n"+
4046
+ "<sheet name=\"Sheet4\">\n"+
4047
+ emit_cell(1, 1, "date", "2007-06-16")+
4048
+ emit_cell(1, 2, "float", "10.0")+
4049
+ emit_cell(1, 3, "float", "10.0")+
4050
+ emit_cell(1, 4, "float", "10.0")+
4051
+ emit_cell(1, 5, "float", "10.0")+
4052
+ "</sheet>\n"+
4053
+ "<sheet name=\"Sheet5\">\n"+
4054
+ emit_cell(1, 1, "float", "1.0")+
4055
+ emit_cell(1, 2, "float", "5.0")+
4056
+ emit_cell(1, 3, "float", "5.0")+
4057
+ emit_cell(2, 1, "float", "2.0")+
4058
+ emit_cell(3, 1, "float", "3.0")+
4059
+ emit_cell(4, 1, "date", "2007-11-21")+
4060
+ emit_cell(4, 2, "date", "2007-11-21")+
4061
+ emit_cell(4, 3, "date", "2007-11-21")+
4062
+ emit_cell(4, 4, "date", "2007-11-21")+
4063
+ emit_cell(4, 5, "date", "2007-11-21")+
4064
+ emit_cell(5, 1, "float", "42.0")+
4065
+ emit_cell(5, 2, "float", "42.0")+
4066
+ emit_cell(5, 3, "float", "42.0")+
4067
+ emit_cell(5, 4, "float", "42.0")+
4068
+ emit_cell(5, 5, "float", "42.0")+
4069
+ emit_cell(6, 1, "string", "ABC")+
4070
+ emit_cell(6, 2, "string", "ABC")+
4071
+ emit_cell(6, 3, "string", "ABC")+
4072
+ emit_cell(6, 4, "string", "ABC")+
4073
+ emit_cell(6, 5, "string", "ABC")+
4074
+ "</sheet>\n"+
4075
+ ""
4076
+ # oo.default_sheet = oo.sheets.first
4077
+ assert_equal expected, oo.to_xml
4078
+ end
4079
+ end
4080
+ end
4081
+
4082
+ def test_invalid_iconv_from_ms
4083
+ #TODO: does only run within a darwin-environment
4084
+ if RUBY_PLATFORM.downcase =~ /darwin/
4085
+ assert_nothing_raised() {
4086
+ oo = Excel.new(File.join("test","ms.xls"))
4087
+ }
4088
+ end
4089
+ end
4090
+
3104
4091
  end # class