roo 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/roo/version.rb CHANGED
@@ -2,7 +2,7 @@ module Roo #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 5
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
Binary file
data/test/numbers1.ods CHANGED
Binary file
Binary file
Binary file
data/test/test_roo.rb CHANGED
@@ -4,13 +4,13 @@ require 'fileutils'
4
4
  include FileUtils
5
5
 
6
6
  class TestRoo < Test::Unit::TestCase
7
-
7
+
8
8
  OPENOFFICE = true # do Openoffice-Spreadsheet Tests?
9
9
  EXCEL = true # do Excel Tests?
10
10
  GOOGLE = false # do Google-Spreadsheet Tests?
11
11
 
12
12
  OPENOFFICEWRITE = false # experimental: write access with OO-Documents
13
-
13
+
14
14
  # helper method
15
15
  def local_only
16
16
  if ENV["roo_local"] == "thomas-p"
@@ -34,12 +34,14 @@ class TestRoo < Test::Unit::TestCase
34
34
 
35
35
  def setup
36
36
  if GOOGLE
37
- @goo = Google.new(ENV['GOOGLE_MAIL'],
38
- ENV['GOOGLE_PASSWORD'],
39
- ENV['GOOGLE_KEY'])
37
+ after Date.new(2007,8,15) do
38
+ @goo = Google.new(ENV['GOOGLE_MAIL'],
39
+ ENV['GOOGLE_PASSWORD'],
40
+ ENV['GOOGLE_KEY'],"Roo Testspreadheet")
41
+ end
40
42
  end
41
- end
42
-
43
+ end
44
+
43
45
  def test_letters
44
46
  assert_equal 1, Openoffice.letter_to_number('A')
45
47
  assert_equal 1, Openoffice.letter_to_number('a')
@@ -50,62 +52,80 @@ class TestRoo < Test::Unit::TestCase
50
52
  assert_equal 27, Openoffice.letter_to_number('Aa')
51
53
  assert_equal 27, Openoffice.letter_to_number('aa')
52
54
  end
53
-
55
+
54
56
  def test_sheets
55
57
  if OPENOFFICE
56
58
  oo = Openoffice.new(File.join("test","numbers1.ods"))
57
59
  assert_equal ["Tabelle1","Name of Sheet 2","Sheet3","Sheet4","Sheet5"], oo.sheets
60
+ assert_raise(RangeError) {
61
+ oo.default_sheet = "no_sheet"
62
+ }
63
+ assert_raise(TypeError) {
64
+ oo.default_sheet = [1,2,3]
65
+ }
58
66
  end
59
67
  if EXCEL
60
68
  oo = Excel.new(File.join("test","numbers1.xls"))
61
69
  assert_equal ["Tabelle1","Name of Sheet 2","Sheet3","Sheet4","Sheet5"], oo.sheets
70
+ assert_raise(RangeError) {
71
+ oo.default_sheet = "no_sheet"
72
+ }
73
+ assert_raise(TypeError) {
74
+ oo.default_sheet = [1,2,3]
75
+ }
62
76
  end
63
77
  if GOOGLE
64
78
  after Date.new(2007,6,10) do
65
79
  assert_equal "Testspreadsheet Roo", @goo.title
66
80
  end
67
81
  assert_equal ["Sheet eins","Sheet zwei","Sheet drei"], @goo.sheets
82
+ assert_raise(RangeError) {
83
+ oo.default_sheet = "no_sheet"
84
+ }
85
+ assert_raise(TypeError) {
86
+ oo.default_sheet = [1,2,3]
87
+ }
68
88
  end
69
89
  end
70
-
90
+
71
91
  def test_cell
72
92
  if OPENOFFICE
73
- oo = Openoffice.new(File.join("test","numbers1.ods"))
74
- oo.default_sheet = oo.sheets.first
75
- assert_equal 1, oo.cell(1,1)
76
- assert_equal 2, oo.cell(1,2)
77
- assert_equal 3, oo.cell(1,3)
78
- assert_equal 4, oo.cell(1,4)
79
- assert_equal 5, oo.cell(2,1)
80
- assert_equal 6, oo.cell(2,2)
81
- assert_equal 7, oo.cell(2,3)
82
- assert_equal 8, oo.cell(2,4)
83
- assert_equal 9, oo.cell(2,5)
84
- assert_equal "test", oo.cell(2,6)
85
- # assert_equal "string", oo.celltype(2,6)
86
- assert_equal :string, oo.celltype(2,6)
87
- assert_equal 11, oo.cell(2,7)
88
- # assert_equal "float", oo.celltype(2,7)
89
- assert_equal :float, oo.celltype(2,7)
90
-
91
- assert_equal 10, oo.cell(4,1)
92
- assert_equal 11, oo.cell(4,2)
93
- assert_equal 12, oo.cell(4,3)
94
- assert_equal 13, oo.cell(4,4)
95
- assert_equal 14, oo.cell(4,5)
96
-
97
- assert_equal 10, oo.cell(4,'A')
98
- assert_equal 11, oo.cell(4,'B')
99
- assert_equal 12, oo.cell(4,'C')
100
- assert_equal 13, oo.cell(4,'D')
101
- assert_equal 14, oo.cell(4,'E')
102
-
103
- # assert_equal "date", oo.celltype(5,1)
104
- assert_equal :date, oo.celltype(5,1)
105
- assert_equal Date.new(1961,11,21), oo.cell(5,1)
106
- assert_equal "1961-11-21", oo.cell(5,1).to_s
107
- end
108
-
93
+ oo = Openoffice.new(File.join("test","numbers1.ods"))
94
+ oo.default_sheet = oo.sheets.first
95
+ assert_equal 1, oo.cell(1,1)
96
+ assert_equal 2, oo.cell(1,2)
97
+ assert_equal 3, oo.cell(1,3)
98
+ assert_equal 4, oo.cell(1,4)
99
+ assert_equal 5, oo.cell(2,1)
100
+ assert_equal 6, oo.cell(2,2)
101
+ assert_equal 7, oo.cell(2,3)
102
+ assert_equal 8, oo.cell(2,4)
103
+ assert_equal 9, oo.cell(2,5)
104
+ assert_equal "test", oo.cell(2,6)
105
+ # assert_equal "string", oo.celltype(2,6)
106
+ assert_equal :string, oo.celltype(2,6)
107
+ assert_equal 11, oo.cell(2,7)
108
+ # assert_equal "float", oo.celltype(2,7)
109
+ assert_equal :float, oo.celltype(2,7)
110
+
111
+ assert_equal 10, oo.cell(4,1)
112
+ assert_equal 11, oo.cell(4,2)
113
+ assert_equal 12, oo.cell(4,3)
114
+ assert_equal 13, oo.cell(4,4)
115
+ assert_equal 14, oo.cell(4,5)
116
+
117
+ assert_equal 10, oo.cell(4,'A')
118
+ assert_equal 11, oo.cell(4,'B')
119
+ assert_equal 12, oo.cell(4,'C')
120
+ assert_equal 13, oo.cell(4,'D')
121
+ assert_equal 14, oo.cell(4,'E')
122
+
123
+ # assert_equal "date", oo.celltype(5,1)
124
+ assert_equal :date, oo.celltype(5,1)
125
+ assert_equal Date.new(1961,11,21), oo.cell(5,1)
126
+ assert_equal "1961-11-21", oo.cell(5,1).to_s
127
+ end
128
+
109
129
  if EXCEL
110
130
  oo = Excel.new(File.join("test","numbers1.xls"))
111
131
  oo.default_sheet = oo.sheets.first
@@ -124,25 +144,25 @@ class TestRoo < Test::Unit::TestCase
124
144
  assert_equal 11, oo.cell(2,7)
125
145
  # assert_equal "float", oo.celltype(2,7)
126
146
  assert_equal :float, oo.celltype(2,7)
127
-
147
+
128
148
  assert_equal 10, oo.cell(4,1)
129
149
  assert_equal 11, oo.cell(4,2)
130
150
  assert_equal 12, oo.cell(4,3)
131
151
  assert_equal 13, oo.cell(4,4)
132
152
  assert_equal 14, oo.cell(4,5)
133
-
153
+
134
154
  assert_equal 10, oo.cell(4,'A')
135
155
  assert_equal 11, oo.cell(4,'B')
136
156
  assert_equal 12, oo.cell(4,'C')
137
157
  assert_equal 13, oo.cell(4,'D')
138
158
  assert_equal 14, oo.cell(4,'E')
139
-
159
+
140
160
  # assert_equal "date", oo.celltype(5,1)
141
161
  assert_equal :date, oo.celltype(5,1)
142
162
  assert_equal Date.new(1961,11,21), oo.cell(5,1)
143
163
  assert_equal "1961-11-21", oo.cell(5,1).to_s
144
164
  end
145
-
165
+
146
166
  if GOOGLE
147
167
  @goo.default_sheet = 1 # @goo.sheets.first
148
168
  assert_equal 1, @goo.cell(1,1).to_i
@@ -162,19 +182,19 @@ class TestRoo < Test::Unit::TestCase
162
182
  # assert_equal "float", @goo.celltype(2,7)
163
183
  assert_equal :float, @goo.celltype(2,7)
164
184
  end
165
-
185
+
166
186
  assert_equal 10, @goo.cell(4,1).to_i
167
187
  assert_equal 11, @goo.cell(4,2).to_i
168
188
  assert_equal 12, @goo.cell(4,3).to_i
169
189
  assert_equal 13, @goo.cell(4,4).to_i
170
190
  assert_equal 14, @goo.cell(4,5).to_i
171
-
191
+
172
192
  assert_equal 10, @goo.cell(4,'A').to_i
173
193
  assert_equal 11, @goo.cell(4,'B').to_i
174
194
  assert_equal 12, @goo.cell(4,'C').to_i
175
195
  assert_equal 13, @goo.cell(4,'D').to_i
176
196
  assert_equal 14, @goo.cell(4,'E').to_i
177
-
197
+
178
198
  after Date.new(2007,6,15) do
179
199
  # assert_equal "date", @goo.celltype(5,1)
180
200
  assert_equal :date, @goo.celltype(5,1)
@@ -186,385 +206,398 @@ class TestRoo < Test::Unit::TestCase
186
206
  before Date.new(2007,6,15) do
187
207
  assert_equal "21/11/1961", @goo.cell(5,1)
188
208
  end
189
- end # GOOGLE
190
- end
191
-
192
- def test_cell_address
193
- if OPENOFFICE
194
- oo = Openoffice.new(File.join("test","numbers1.ods"))
195
- oo.default_sheet = oo.sheets.first
196
- assert_equal "tata", oo.cell(6,1)
197
- assert_equal "tata", oo.cell(6,'A')
198
- assert_equal "tata", oo.cell('A',6)
199
- assert_equal "tata", oo.cell(6,'a')
200
- assert_equal "tata", oo.cell('a',6)
201
-
202
- assert_raise(ArgumentError) {
203
- assert_equal "tata", oo.cell('a','f')
204
- }
205
- assert_raise(ArgumentError) {
206
- assert_equal "tata", oo.cell('f','a')
207
- }
208
- assert_equal "thisisc8", oo.cell(8,3)
209
- assert_equal "thisisc8", oo.cell(8,'C')
210
- assert_equal "thisisc8", oo.cell('C',8)
211
- assert_equal "thisisc8", oo.cell(8,'c')
212
- assert_equal "thisisc8", oo.cell('c',8)
213
-
214
- assert_equal "thisisd9", oo.cell('d',9)
215
- assert_equal "thisisa11", oo.cell('a',11)
216
- end
217
-
218
- if EXCEL
219
- oo = Excel.new(File.join("test","numbers1.xls"))
220
- oo.default_sheet = oo.sheets.first
221
- assert_equal "tata", oo.cell(6,1)
222
- assert_equal "tata", oo.cell(6,'A')
223
- assert_equal "tata", oo.cell('A',6)
224
- assert_equal "tata", oo.cell(6,'a')
225
- assert_equal "tata", oo.cell('a',6)
226
-
227
- assert_raise(ArgumentError) {
228
- assert_equal "tata", oo.cell('a','f')
229
- }
230
- assert_raise(ArgumentError) {
231
- assert_equal "tata", oo.cell('f','a')
232
- }
233
-
234
- assert_equal "thisisc8", oo.cell(8,3)
235
- assert_equal "thisisc8", oo.cell(8,'C')
236
- assert_equal "thisisc8", oo.cell('C',8)
237
- assert_equal "thisisc8", oo.cell(8,'c')
238
- assert_equal "thisisc8", oo.cell('c',8)
239
-
240
- assert_equal "thisisd9", oo.cell('d',9)
241
- assert_equal "thisisa11", oo.cell('a',11)
242
- #assert_equal "lulua", oo.cell('b',10)
243
- end
244
-
245
- if GOOGLE
246
- @goo.default_sheet = 1 # @goo.sheets.first
247
- assert_equal "tata", @goo.cell(6,1)
248
- assert_equal "tata", @goo.cell(6,'A')
249
- assert_equal "tata", @goo.cell('A',6)
250
- assert_equal "tata", @goo.cell(6,'a')
251
- assert_equal "tata", @goo.cell('a',6)
252
-
253
- assert_equal "thisisc8", @goo.cell(8,3)
254
- assert_equal "thisisc8", @goo.cell(8,'C')
255
- assert_equal "thisisc8", @goo.cell('C',8)
256
- assert_equal "thisisc8", @goo.cell(8,'c')
257
- assert_equal "thisisc8", @goo.cell('c',8)
258
-
259
- assert_equal "thisisd9", @goo.cell('d',9)
260
- assert_equal "thisisa11", @goo.cell('a',11)
261
- end
209
+ end # GOOGLE
210
+ end
211
+
212
+ def test_celltype
213
+ ###
214
+ if OPENOFFICE
215
+ oo = Openoffice.new(File.join("test","numbers1.ods"))
216
+ oo.default_sheet = oo.sheets.first
217
+ assert_equal :string, oo.celltype(2,6)
262
218
  end
263
-
264
- # Version of the (XML) office document
265
- # please note that "1.0" is returned even if it was created with OpenOffice V. 2.0
266
- def test_officeversion
267
- #-- OpenOffice
219
+ if EXCEL
220
+ oo = Excel.new(File.join("test","numbers1.xls"))
221
+ oo.default_sheet = oo.sheets.first
222
+ assert_equal :string, oo.celltype(2,6)
223
+ end
224
+ if GOOGLE
225
+ oo = Google.new(File.join("test","nxxxxxxxxxxxxxumbers1.xls"))
226
+ oo.default_sheet = oo.sheets.first
227
+ assert_equal :string, oo.celltype(2,6)
228
+ end
229
+ end
230
+
231
+ def test_cell_address
232
+ if OPENOFFICE
268
233
  oo = Openoffice.new(File.join("test","numbers1.ods"))
269
- assert_equal "1.0", oo.officeversion
270
- if EXCEL
271
- # excel does not have a officeversion
272
- # is there a similar version number which ist considerable
273
- #-- Excel
274
- #after Date.new(2007,6,15) do
275
- # oo = Excel.new(File.join("test","numbers1.xls"))
276
- # assert_equal "1.0", oo.officeversion
277
- #end
278
- end
279
- #-- Google
280
- if GOOGLE
281
- after Date.new(2007,6,15) do
282
- assert_equal "1.0", @goo.officeversion
283
- end
234
+ oo.default_sheet = oo.sheets.first
235
+ assert_equal "tata", oo.cell(6,1)
236
+ assert_equal "tata", oo.cell(6,'A')
237
+ assert_equal "tata", oo.cell('A',6)
238
+ assert_equal "tata", oo.cell(6,'a')
239
+ assert_equal "tata", oo.cell('a',6)
240
+
241
+ assert_raise(ArgumentError) {
242
+ assert_equal "tata", oo.cell('a','f')
243
+ }
244
+ assert_raise(ArgumentError) {
245
+ assert_equal "tata", oo.cell('f','a')
246
+ }
247
+ assert_equal "thisisc8", oo.cell(8,3)
248
+ assert_equal "thisisc8", oo.cell(8,'C')
249
+ assert_equal "thisisc8", oo.cell('C',8)
250
+ assert_equal "thisisc8", oo.cell(8,'c')
251
+ assert_equal "thisisc8", oo.cell('c',8)
252
+
253
+ assert_equal "thisisd9", oo.cell('d',9)
254
+ assert_equal "thisisa11", oo.cell('a',11)
255
+ end
256
+
257
+ if EXCEL
258
+ oo = Excel.new(File.join("test","numbers1.xls"))
259
+ oo.default_sheet = oo.sheets.first
260
+ assert_equal "tata", oo.cell(6,1)
261
+ assert_equal "tata", oo.cell(6,'A')
262
+ assert_equal "tata", oo.cell('A',6)
263
+ assert_equal "tata", oo.cell(6,'a')
264
+ assert_equal "tata", oo.cell('a',6)
265
+
266
+ assert_raise(ArgumentError) {
267
+ assert_equal "tata", oo.cell('a','f')
268
+ }
269
+ assert_raise(ArgumentError) {
270
+ assert_equal "tata", oo.cell('f','a')
271
+ }
272
+
273
+ assert_equal "thisisc8", oo.cell(8,3)
274
+ assert_equal "thisisc8", oo.cell(8,'C')
275
+ assert_equal "thisisc8", oo.cell('C',8)
276
+ assert_equal "thisisc8", oo.cell(8,'c')
277
+ assert_equal "thisisc8", oo.cell('c',8)
278
+
279
+ assert_equal "thisisd9", oo.cell('d',9)
280
+ assert_equal "thisisa11", oo.cell('a',11)
281
+ #assert_equal "lulua", oo.cell('b',10)
282
+ end
283
+
284
+ if GOOGLE
285
+ @goo.default_sheet = 1 # @goo.sheets.first
286
+ assert_equal "tata", @goo.cell(6,1)
287
+ assert_equal "tata", @goo.cell(6,'A')
288
+ assert_equal "tata", @goo.cell('A',6)
289
+ assert_equal "tata", @goo.cell(6,'a')
290
+ assert_equal "tata", @goo.cell('a',6)
291
+
292
+ assert_equal "thisisc8", @goo.cell(8,3)
293
+ assert_equal "thisisc8", @goo.cell(8,'C')
294
+ assert_equal "thisisc8", @goo.cell('C',8)
295
+ assert_equal "thisisc8", @goo.cell(8,'c')
296
+ assert_equal "thisisc8", @goo.cell('c',8)
297
+
298
+ assert_equal "thisisd9", @goo.cell('d',9)
299
+ assert_equal "thisisa11", @goo.cell('a',11)
300
+ end
301
+ end
302
+
303
+ # Version of the (XML) office document
304
+ # please note that "1.0" is returned even if it was created with OpenOffice V. 2.0
305
+ def test_officeversion
306
+ #-- OpenOffice
307
+ oo = Openoffice.new(File.join("test","numbers1.ods"))
308
+ assert_equal "1.0", oo.officeversion
309
+ if EXCEL
310
+ # excel does not have a officeversion
311
+ end
312
+ #-- Google
313
+ if GOOGLE
314
+ after Date.new(2007,6,15) do
315
+ assert_equal "1.0", @goo.officeversion
284
316
  end
285
317
  end
286
-
287
- def test_rows
288
- #-- OpenOffice
289
- oo = Openoffice.new(File.join("test","numbers1.ods"))
318
+ end
319
+
320
+ def test_rows
321
+ #-- OpenOffice
322
+ oo = Openoffice.new(File.join("test","numbers1.ods"))
323
+ oo.default_sheet = oo.sheets.first
324
+ assert_equal 41, oo.cell('a',12)
325
+ assert_equal 42, oo.cell('b',12)
326
+ assert_equal 43, oo.cell('c',12)
327
+ assert_equal 44, oo.cell('d',12)
328
+ assert_equal 45, oo.cell('e',12)
329
+ assert_equal [41.0,42.0,43.0,44.0,45.0], oo.row(12)
330
+ assert_equal "einundvierzig", oo.cell('a',16)
331
+ assert_equal "zweiundvierzig", oo.cell('b',16)
332
+ assert_equal "dreiundvierzig", oo.cell('c',16)
333
+ assert_equal "vierundvierzig", oo.cell('d',16)
334
+ assert_equal "fuenfundvierzig", oo.cell('e',16)
335
+ assert_equal ["einundvierzig", "zweiundvierzig", "dreiundvierzig", "vierundvierzig", "fuenfundvierzig"], oo.row(16)
336
+ if EXCEL
337
+ #-- Excel
338
+ oo = Excel.new(File.join("test","numbers1.xls"))
290
339
  oo.default_sheet = oo.sheets.first
291
340
  assert_equal 41, oo.cell('a',12)
292
341
  assert_equal 42, oo.cell('b',12)
293
342
  assert_equal 43, oo.cell('c',12)
294
343
  assert_equal 44, oo.cell('d',12)
295
344
  assert_equal 45, oo.cell('e',12)
296
- assert_equal [41.0,42.0,43.0,44.0,45.0], oo.row(12)
345
+ assert_equal [41,42,43,44,45], oo.row(12)
297
346
  assert_equal "einundvierzig", oo.cell('a',16)
298
347
  assert_equal "zweiundvierzig", oo.cell('b',16)
299
348
  assert_equal "dreiundvierzig", oo.cell('c',16)
300
349
  assert_equal "vierundvierzig", oo.cell('d',16)
301
350
  assert_equal "fuenfundvierzig", oo.cell('e',16)
302
- assert_equal ["einundvierzig", "zweiundvierzig", "dreiundvierzig", "vierundvierzig", "fuenfundvierzig"], oo.row(16)
303
- if EXCEL
304
- #-- Excel
305
- oo = Excel.new(File.join("test","numbers1.xls"))
306
- oo.default_sheet = oo.sheets.first
351
+ assert_equal ["einundvierzig",
352
+ "zweiundvierzig",
353
+ "dreiundvierzig",
354
+ "vierundvierzig",
355
+ "fuenfundvierzig"], oo.row(16)
356
+ end
357
+ after Date.new(2007,6,17) do
358
+ #-- GOOGLE
359
+ if GOOGLE
360
+ oo = Google.new(File.join("test","numbers1.xls"))
361
+ oo.default_sheet = 1 # oo.sheets.first
307
362
  assert_equal 41, oo.cell('a',12)
308
363
  assert_equal 42, oo.cell('b',12)
309
364
  assert_equal 43, oo.cell('c',12)
310
365
  assert_equal 44, oo.cell('d',12)
311
366
  assert_equal 45, oo.cell('e',12)
312
- assert_equal [41,42,43,44,45], oo.row(12)
367
+ assert_equal [41.0,42.0,43.0,44.0,45.0], oo.row(12)
313
368
  assert_equal "einundvierzig", oo.cell('a',16)
314
369
  assert_equal "zweiundvierzig", oo.cell('b',16)
315
370
  assert_equal "dreiundvierzig", oo.cell('c',16)
316
371
  assert_equal "vierundvierzig", oo.cell('d',16)
317
372
  assert_equal "fuenfundvierzig", oo.cell('e',16)
373
+ assert_equal "xxxfuenfundvierzig", oo.cell('e',16)
318
374
  assert_equal ["einundvierzig",
319
- "zweiundvierzig",
320
- "dreiundvierzig",
321
- "vierundvierzig",
322
- "fuenfundvierzig"], oo.row(16)
323
- end
324
- after Date.new(2007,6,17) do
325
- #-- GOOGLE
326
- if GOOGLE
327
- oo = Google.new(File.join("test","numbers1.xls"))
328
- oo.default_sheet = 1 # oo.sheets.first
329
- assert_equal 41, oo.cell('a',12)
330
- assert_equal 42, oo.cell('b',12)
331
- assert_equal 43, oo.cell('c',12)
332
- assert_equal 44, oo.cell('d',12)
333
- assert_equal 45, oo.cell('e',12)
334
- assert_equal [41.0,42.0,43.0,44.0,45.0], oo.row(12)
335
- assert_equal "einundvierzig", oo.cell('a',16)
336
- assert_equal "zweiundvierzig", oo.cell('b',16)
337
- assert_equal "dreiundvierzig", oo.cell('c',16)
338
- assert_equal "vierundvierzig", oo.cell('d',16)
339
- assert_equal "fuenfundvierzig", oo.cell('e',16)
340
- assert_equal "xxxfuenfundvierzig", oo.cell('e',16)
341
- assert_equal ["einundvierzig",
342
- "zweiundvierzig",
343
- "dreiundvierzig",
344
- "vierundvierzig",
345
- "fuenfundvierzig"], oo.row(16)
346
- end
375
+ "zweiundvierzig",
376
+ "dreiundvierzig",
377
+ "vierundvierzig",
378
+ "fuenfundvierzig"], oo.row(16)
347
379
  end
348
380
  end
349
-
350
- def test_last_row
351
- if OPENOFFICE
352
- oo = Openoffice.new(File.join("test","numbers1.ods"))
353
- oo.default_sheet = oo.sheets.first
354
- assert_equal 18, oo.last_row
355
- end
356
- if EXCEL
357
- oo = Excel.new(File.join("test","numbers1.xls"))
358
- oo.default_sheet = oo.sheets.first
359
- assert_equal 18, oo.last_row
360
- end
361
- if GOOGLE
362
- @goo.default_sheet = @goo.sheets.first
363
- assert_equal 18, @goo.last_row
364
- assert_equal "xxx", @goo.to_s, @goo.to_s
365
- end
381
+ end
382
+
383
+ def test_last_row
384
+ if OPENOFFICE
385
+ oo = Openoffice.new(File.join("test","numbers1.ods"))
386
+ oo.default_sheet = oo.sheets.first
387
+ assert_equal 18, oo.last_row
366
388
  end
367
-
368
- def test_last_column
369
- if OPENOFFICE
370
- oo = Openoffice.new(File.join("test","numbers1.ods"))
371
- oo.default_sheet = oo.sheets.first
372
- assert_equal 7, oo.last_column
373
- end
374
- if EXCEL
375
- #-- Excel
376
- oo = Excel.new(File.join("test","numbers1.xls"))
377
- oo.default_sheet = oo.sheets.first
378
- assert_equal 7, oo.last_column
379
- end
380
- if GOOGLE
381
- #-- Google
382
- @goo.default_sheet = @goo.sheets.first
383
- assert_equal 7, @goo.last_column
384
- end
389
+ if EXCEL
390
+ oo = Excel.new(File.join("test","numbers1.xls"))
391
+ oo.default_sheet = oo.sheets.first
392
+ assert_equal 18, oo.last_row
385
393
  end
386
-
387
- def test_last_column_as_letter
388
- #-- OpenOffice
394
+ if GOOGLE
395
+ @goo.default_sheet = @goo.sheets.first
396
+ assert_equal 18, @goo.last_row
397
+ assert_equal "xxx", @goo.to_s, @goo.to_s
398
+ end
399
+ end
400
+
401
+ def test_last_column
402
+ if OPENOFFICE
389
403
  oo = Openoffice.new(File.join("test","numbers1.ods"))
390
404
  oo.default_sheet = oo.sheets.first
391
- assert_equal 'G', oo.last_column_as_letter
392
- if EXCEL
393
- #-- Excel
394
- oo = Excel.new(File.join("test","numbers1.xls"))
395
- oo.default_sheet = 1 # oo.sheets.first
396
- assert_equal 'G', oo.last_column_as_letter
397
- end
398
- if GOOGLE
399
- #-- Google
400
- @goo.default_sheet = @goo.sheets.first
401
- assert_equal 'G', @goo.last_column_as_letter
402
- end
405
+ assert_equal 7, oo.last_column
403
406
  end
404
-
405
- def test_first_row
406
- #-- OpenOffice
407
- oo = Openoffice.new(File.join("test","numbers1.ods"))
407
+ if EXCEL
408
+ #-- Excel
409
+ oo = Excel.new(File.join("test","numbers1.xls"))
408
410
  oo.default_sheet = oo.sheets.first
411
+ assert_equal 7, oo.last_column
412
+ end
413
+ if GOOGLE
414
+ #-- Google
415
+ @goo.default_sheet = @goo.sheets.first
416
+ assert_equal 7, @goo.last_column
417
+ end
418
+ end
419
+
420
+ def test_last_column_as_letter
421
+ #-- OpenOffice
422
+ oo = Openoffice.new(File.join("test","numbers1.ods"))
423
+ oo.default_sheet = oo.sheets.first
424
+ assert_equal 'G', oo.last_column_as_letter
425
+ if EXCEL
426
+ #-- Excel
427
+ oo = Excel.new(File.join("test","numbers1.xls"))
428
+ oo.default_sheet = 1 # oo.sheets.first
429
+ assert_equal 'G', oo.last_column_as_letter
430
+ end
431
+ if GOOGLE
432
+ #-- Google
433
+ @goo.default_sheet = @goo.sheets.first
434
+ assert_equal 'G', @goo.last_column_as_letter
435
+ end
436
+ end
437
+
438
+ def test_first_row
439
+ #-- OpenOffice
440
+ oo = Openoffice.new(File.join("test","numbers1.ods"))
441
+ oo.default_sheet = oo.sheets.first
442
+ assert_equal 1, oo.first_row
443
+ if EXCEL
444
+ #-- Excel
445
+ oo = Excel.new(File.join("test","numbers1.xls"))
446
+ oo.default_sheet = 1 # oo.sheets.first
409
447
  assert_equal 1, oo.first_row
410
- if EXCEL
411
- #-- Excel
412
- oo = Excel.new(File.join("test","numbers1.xls"))
413
- oo.default_sheet = 1 # oo.sheets.first
414
- assert_equal 1, oo.first_row
415
- end
416
- if GOOGLE
417
- #-- Google
418
- @goo.default_sheet = @goo.sheets.first
419
- assert_equal 1, @goo.first_row
420
- end
421
448
  end
422
-
423
- def test_first_column
424
- #-- OpenOffice
425
- oo = Openoffice.new(File.join("test","numbers1.ods"))
426
- oo.default_sheet = oo.sheets.first
449
+ if GOOGLE
450
+ #-- Google
451
+ @goo.default_sheet = @goo.sheets.first
452
+ assert_equal 1, @goo.first_row
453
+ end
454
+ end
455
+
456
+ def test_first_column
457
+ #-- OpenOffice
458
+ oo = Openoffice.new(File.join("test","numbers1.ods"))
459
+ oo.default_sheet = oo.sheets.first
460
+ assert_equal 1, oo.first_column
461
+ if EXCEL
462
+ #-- Excel
463
+ oo = Excel.new(File.join("test","numbers1.xls"))
464
+ oo.default_sheet = 1 # oo.sheets.first
427
465
  assert_equal 1, oo.first_column
428
- if EXCEL
429
- #-- Excel
430
- oo = Excel.new(File.join("test","numbers1.xls"))
431
- oo.default_sheet = 1 # oo.sheets.first
432
- assert_equal 1, oo.first_column
433
- end
434
- if GOOGLE
435
- #-- Google
436
- @goo.default_sheet = 1 # @goo.sheets.first
437
- assert_equal 1, @goo.first_column
438
- end
439
466
  end
440
-
441
- def test_first_column_as_letter
442
- #-- OpenOffice
443
- oo = Openoffice.new(File.join("test","numbers1.ods"))
444
- oo.default_sheet = oo.sheets.first
467
+ if GOOGLE
468
+ #-- Google
469
+ @goo.default_sheet = 1 # @goo.sheets.first
470
+ assert_equal 1, @goo.first_column
471
+ end
472
+ end
473
+
474
+ def test_first_column_as_letter
475
+ #-- OpenOffice
476
+ oo = Openoffice.new(File.join("test","numbers1.ods"))
477
+ oo.default_sheet = oo.sheets.first
478
+ assert_equal 'A', oo.first_column_as_letter
479
+ if EXCEL
480
+ #-- Excel
481
+ oo = Excel.new(File.join("test","numbers1.xls"))
482
+ oo.default_sheet = 1 # oo.sheets.first
445
483
  assert_equal 'A', oo.first_column_as_letter
446
- if EXCEL
447
- #-- Excel
448
- oo = Excel.new(File.join("test","numbers1.xls"))
449
- oo.default_sheet = 1 # oo.sheets.first
450
- assert_equal 'A', oo.first_column_as_letter
451
- end
452
- if GOOGLE
453
- #-- Google
454
- @goo.default_sheet = @goo.sheets.first
455
- assert_equal 'A', @goo.first_column_as_letter
456
- end
457
484
  end
458
-
459
- def test_sheetname
460
- if OPENOFFICE
461
- #-- OpenOffice
462
- oo = Openoffice.new(File.join("test","numbers1.ods"))
463
- oo.default_sheet = "Name of Sheet 2"
464
- assert_equal 'I am sheet 2', oo.cell('C',5)
465
- end
466
- if EXCEL
467
- oo = Excel.new(File.join("test","numbers1.xls"))
468
- oo.default_sheet = "Name of Sheet 2"
469
- assert_equal 'I am sheet 2', oo.cell('C',5)
470
- end
485
+ if GOOGLE
486
+ #-- Google
487
+ @goo.default_sheet = @goo.sheets.first
488
+ assert_equal 'A', @goo.first_column_as_letter
471
489
  end
472
-
473
- def test_boundaries
490
+ end
491
+
492
+ def test_sheetname
493
+ if OPENOFFICE
474
494
  #-- OpenOffice
475
495
  oo = Openoffice.new(File.join("test","numbers1.ods"))
476
496
  oo.default_sheet = "Name of Sheet 2"
497
+ assert_equal 'I am sheet 2', oo.cell('C',5)
498
+ end
499
+ if EXCEL
500
+ oo = Excel.new(File.join("test","numbers1.xls"))
501
+ oo.default_sheet = "Name of Sheet 2"
502
+ assert_equal 'I am sheet 2', oo.cell('C',5)
503
+ end
504
+ end
505
+
506
+ def test_boundaries
507
+ #-- OpenOffice
508
+ oo = Openoffice.new(File.join("test","numbers1.ods"))
509
+ oo.default_sheet = "Name of Sheet 2"
510
+ assert_equal 2, oo.first_column
511
+ assert_equal 'B', oo.first_column_as_letter
512
+ assert_equal 5, oo.first_row
513
+ assert_equal 'E', oo.last_column_as_letter
514
+ assert_equal 14, oo.last_row
515
+ if EXCEL
516
+ #-- Excel
517
+ oo = Excel.new(File.join("test","numbers1.xls"))
518
+ oo.default_sheet = 2 # "Name of Sheet 2"
477
519
  assert_equal 2, oo.first_column
478
520
  assert_equal 'B', oo.first_column_as_letter
479
521
  assert_equal 5, oo.first_row
480
522
  assert_equal 'E', oo.last_column_as_letter
481
523
  assert_equal 14, oo.last_row
482
- if EXCEL
483
- #-- Excel
484
- oo = Excel.new(File.join("test","numbers1.xls"))
485
- oo.default_sheet = 2 # "Name of Sheet 2"
486
- assert_equal 2, oo.first_column
487
- assert_equal 'B', oo.first_column_as_letter
488
- assert_equal 5, oo.first_row
489
- assert_equal 'E', oo.last_column_as_letter
490
- assert_equal 14, oo.last_row
491
- end
492
524
  end
493
-
494
- def test_multiple_letters
495
- #-- OpenOffice
496
- oo = Openoffice.new(File.join("test","numbers1.ods"))
497
- oo.default_sheet = "Sheet3"
525
+ end
526
+
527
+ def test_multiple_letters
528
+ #-- OpenOffice
529
+ oo = Openoffice.new(File.join("test","numbers1.ods"))
530
+ oo.default_sheet = "Sheet3"
531
+ assert_equal "i am AA", oo.cell('AA',1)
532
+ assert_equal "i am AB", oo.cell('AB',1)
533
+ assert_equal "i am BA", oo.cell('BA',1)
534
+ assert_equal 'BA', oo.last_column_as_letter
535
+ assert_equal "i am BA", oo.cell(1,'BA')
536
+ if EXCEL
537
+ #-- Excel
538
+ oo = Excel.new(File.join("test","numbers1.xls"))
539
+ oo.default_sheet = 3 # "Sheet3"
498
540
  assert_equal "i am AA", oo.cell('AA',1)
499
541
  assert_equal "i am AB", oo.cell('AB',1)
500
542
  assert_equal "i am BA", oo.cell('BA',1)
501
543
  assert_equal 'BA', oo.last_column_as_letter
502
544
  assert_equal "i am BA", oo.cell(1,'BA')
503
- if EXCEL
504
- #-- Excel
505
- oo = Excel.new(File.join("test","numbers1.xls"))
506
- oo.default_sheet = 3 # "Sheet3"
507
- assert_equal "i am AA", oo.cell('AA',1)
508
- assert_equal "i am AB", oo.cell('AB',1)
509
- assert_equal "i am BA", oo.cell('BA',1)
510
- assert_equal 'BA', oo.last_column_as_letter
511
- assert_equal "i am BA", oo.cell(1,'BA')
512
- end
513
545
  end
514
-
515
- def test_setting_cell
516
- assert true
517
- end
518
-
519
- def test_argument_error
520
- if EXCEL
521
- oo = Excel.new(File.join("test","numbers1.xls"))
522
- before Date.new(2007,7,20) do
523
- assert_raise(ArgumentError) {
524
- oo.default_sheet = "first sheet"
525
- }
526
- end
527
- assert_nothing_raised(ArgumentError) {
528
- oo.default_sheet = 1
546
+ end
547
+
548
+ def test_setting_cell
549
+ assert true
550
+ end
551
+
552
+ def test_argument_error
553
+ if EXCEL
554
+ oo = Excel.new(File.join("test","numbers1.xls"))
555
+ before Date.new(2007,7,20) do
556
+ assert_raise(ArgumentError) {
557
+ oo.default_sheet = "first sheet"
529
558
  }
530
559
  end
560
+ assert_nothing_raised(ArgumentError) {
561
+ oo.default_sheet = 1
562
+ }
531
563
  end
532
-
533
- def test_empty_eh
534
- #-- OpenOffice
535
- oo = Openoffice.new(File.join("test","numbers1.ods"))
536
- oo.default_sheet = oo.sheets.first
564
+ end
565
+
566
+ def test_empty_eh
567
+ #-- OpenOffice
568
+ oo = Openoffice.new(File.join("test","numbers1.ods"))
569
+ oo.default_sheet = oo.sheets.first
570
+ assert oo.empty?('a',14)
571
+ assert ! oo.empty?('a',15)
572
+ assert oo.empty?('a',20)
573
+ if EXCEL
574
+ #-- Excel
575
+ oo = Excel.new(File.join("test","numbers1.xls"))
576
+ oo.default_sheet = 1
537
577
  assert oo.empty?('a',14)
538
578
  assert ! oo.empty?('a',15)
539
579
  assert oo.empty?('a',20)
540
- if EXCEL
541
- #-- Excel
542
- oo = Excel.new(File.join("test","numbers1.xls"))
543
- oo.default_sheet = 1
544
- assert oo.empty?('a',14)
545
- assert ! oo.empty?('a',15)
546
- assert oo.empty?('a',20)
547
- end
548
580
  end
581
+ end
549
582
 
550
- def test_writeopenoffice
551
- if OPENOFFICEWRITE
583
+ def test_writeopenoffice
584
+ if OPENOFFICEWRITE
552
585
  File.cp(File.join("test","numbers1.ods"),
553
- File.join("test","numbers2.ods"))
586
+ File.join("test","numbers2.ods"))
554
587
  File.cp(File.join("test","numbers2.ods"),
555
- File.join("test","bak_numbers2.ods"))
588
+ File.join("test","bak_numbers2.ods"))
556
589
  oo = Openoffice.new(File.join("test","numbers2.ods"))
557
590
  oo.default_sheet = oo.sheets.first
558
591
  oo.first_row.upto(oo.last_row) {|y|
559
592
  oo.first_column.upto(oo.last_column) {|x|
560
- unless oo.empty?(y,x)
593
+ unless oo.empty?(y,x)
561
594
  # oo.set(y, x, oo.cell(y,x) + 7) if oo.celltype(y,x) == "float"
562
595
  oo.set(y, x, oo.cell(y,x) + 7) if oo.celltype(y,x) == :float
563
596
  end
564
597
  }
565
598
  }
566
599
  oo.save
567
-
600
+
568
601
  oo1 = Openoffice.new(File.join("test","numbers2.ods"))
569
602
  oo2 = Openoffice.new(File.join("test","bak_numbers2.ods"))
570
603
  p oo2.to_s
@@ -578,78 +611,78 @@ class TestRoo < Test::Unit::TestCase
578
611
  assert_equal oo2.cell('c',2)+7, oo1.cell('c',2)
579
612
  assert_equal oo2.cell('d',2)+7, oo1.cell('d',2)
580
613
  assert_equal oo2.cell('e',2)+7, oo1.cell('e',2)
581
-
614
+
582
615
  File.cp(File.join("test","bak_numbers2.ods"),
583
- File.join("test","numbers2.ods"))
584
- end
616
+ File.join("test","numbers2.ods"))
585
617
  end
618
+ end
586
619
 
587
- def test_reload
588
- if OPENOFFICE
589
- oo = Openoffice.new(File.join("test","numbers1.ods"))
590
- oo.default_sheet = oo.sheets.first
591
- assert_equal 1, oo.cell(1,1)
620
+ def test_reload
621
+ if OPENOFFICE
622
+ oo = Openoffice.new(File.join("test","numbers1.ods"))
623
+ oo.default_sheet = oo.sheets.first
624
+ assert_equal 1, oo.cell(1,1)
592
625
 
593
- oo.reload
594
- assert_equal 1, oo.cell(1,1)
595
- end
596
- if EXCEL
597
- oo = Excel.new(File.join("test","numbers1.xls"))
598
- oo.default_sheet = 1 # oo.sheets.first
599
- assert_equal 1, oo.cell(1,1)
626
+ oo.reload
627
+ assert_equal 1, oo.cell(1,1)
628
+ end
629
+ if EXCEL
630
+ oo = Excel.new(File.join("test","numbers1.xls"))
631
+ oo.default_sheet = 1 # oo.sheets.first
632
+ assert_equal 1, oo.cell(1,1)
600
633
 
601
- oo.reload
602
- assert_equal 1, oo.cell(1,1)
603
- end
634
+ oo.reload
635
+ assert_equal 1, oo.cell(1,1)
604
636
  end
637
+ end
605
638
 
606
- def test_bug_contiguous_cells
607
- if OPENOFFICE
608
- oo = Openoffice.new(File.join("test","numbers1.ods"))
609
- oo.default_sheet = "Sheet4"
610
- assert_equal Date.new(2007,06,16), oo.cell('a',1)
611
- assert_equal 10, oo.cell('b',1)
612
- assert_equal 10, oo.cell('c',1)
613
- assert_equal 10, oo.cell('d',1)
614
- assert_equal 10, oo.cell('e',1)
615
- end
616
- if EXCEL
617
- oo = Excel.new(File.join("test","numbers1.xls"))
618
- oo.default_sheet = 4
619
- assert_equal Date.new(2007,06,16), oo.cell('a',1)
620
- assert_equal 10, oo.cell('b',1)
621
- assert_equal 10, oo.cell('c',1)
622
- assert_equal 10, oo.cell('d',1)
623
- assert_equal 10, oo.cell('e',1)
624
- end
625
- if GOOGLE
626
- @goo.default_sheet = "Sheet4"
627
- assert_equal Date.new(2007,06,16), @goo.cell('a',1)
628
- assert_equal 10, @goo.cell('b',1)
629
- assert_equal 10, @goo.cell('c',1)
630
- assert_equal 10, @goo.cell('d',1)
631
- assert_equal 10, @goo.cell('e',1)
632
- end
633
- end
639
+ def test_bug_contiguous_cells
640
+ if OPENOFFICE
641
+ oo = Openoffice.new(File.join("test","numbers1.ods"))
642
+ oo.default_sheet = "Sheet4"
643
+ assert_equal Date.new(2007,06,16), oo.cell('a',1)
644
+ assert_equal 10, oo.cell('b',1)
645
+ assert_equal 10, oo.cell('c',1)
646
+ assert_equal 10, oo.cell('d',1)
647
+ assert_equal 10, oo.cell('e',1)
648
+ end
649
+ if EXCEL
650
+ oo = Excel.new(File.join("test","numbers1.xls"))
651
+ oo.default_sheet = 4
652
+ assert_equal Date.new(2007,06,16), oo.cell('a',1)
653
+ assert_equal 10, oo.cell('b',1)
654
+ assert_equal 10, oo.cell('c',1)
655
+ assert_equal 10, oo.cell('d',1)
656
+ assert_equal 10, oo.cell('e',1)
657
+ end
658
+ if GOOGLE
659
+ @goo.default_sheet = "Sheet4"
660
+ assert_equal Date.new(2007,06,16), @goo.cell('a',1)
661
+ assert_equal 10, @goo.cell('b',1)
662
+ assert_equal 10, @goo.cell('c',1)
663
+ assert_equal 10, @goo.cell('d',1)
664
+ assert_equal 10, @goo.cell('e',1)
665
+ end
666
+ end
634
667
 
635
668
  def test_bug_italo_ve
636
669
  if OPENOFFICE
637
670
  oo = Openoffice.new(File.join("test","numbers1.ods"))
638
671
  oo.default_sheet = "Sheet5"
639
- assert_equal 1, oo.cell('A',1)
640
- assert_equal 5, oo.cell('b',1)
641
- assert_equal 5, oo.cell('c',1)
642
- assert_equal 2, oo.cell('a',2)
643
- assert_equal 3, oo.cell('a',3)
672
+ assert_equal 1, oo.cell('A',1)
673
+ assert_equal 5, oo.cell('b',1)
674
+ assert_equal 5, oo.cell('c',1)
675
+ assert_equal 2, oo.cell('a',2)
676
+ assert_equal 3, oo.cell('a',3)
644
677
  end
645
678
  if EXCEL
646
679
  oo = Excel.new(File.join("test","numbers1.xls"))
647
680
  oo.default_sheet = 5
648
- assert_equal 1, oo.cell('A',1)
649
- assert_equal 5, oo.cell('b',1)
650
- assert_equal 5, oo.cell('c',1)
651
- assert_equal 2, oo.cell('a',2)
652
- assert_equal 3, oo.cell('a',3)
681
+ assert_equal 1, oo.cell('A',1)
682
+ assert_equal 5, oo.cell('b',1)
683
+ assert_equal 5, oo.cell('c',1)
684
+ assert_equal 2, oo.cell('a',2)
685
+ assert_equal 3, oo.cell('a',3)
653
686
  end
654
687
  end
655
688
 
@@ -663,91 +696,75 @@ class TestRoo < Test::Unit::TestCase
663
696
  unless oo.empty?(row,col)
664
697
  count += 1
665
698
  a = oo.cell(row,col)
666
- # puts a
667
- # b = gets
699
+ # puts a
700
+ # b = gets
668
701
  end
669
702
  end
670
703
  end
671
704
  puts count.to_s+" cells with content"
672
705
  end
673
706
 
674
- end
675
-
707
+ end
708
+
676
709
  def test_italo_table
677
710
  local_only do
678
- oo = Openoffice.new(File.join("test","simple_spreadsheet_from_italo.ods"))
679
- oo.default_sheet = oo.sheets.first
680
-
681
- assert_equal '1', oo.cell('A',1)
682
- assert_equal '1', oo.cell('B',1)
683
- assert_equal '1', oo.cell('C',1)
684
-
685
- # assert_equal 1, oo.cell('A',2)
686
- # assert_equal 2, oo.cell('B',2)
687
- # assert_equal 1, oo.cell('C',2)
688
- # are stored as strings, not numbers
711
+ oo = Openoffice.new(File.join("test","simple_spreadsheet_from_italo.ods"))
712
+ oo.default_sheet = oo.sheets.first
689
713
 
690
- assert_equal 1, oo.cell('A',2).to_i
691
- assert_equal 2, oo.cell('B',2).to_i
692
- assert_equal 1, oo.cell('C',2).to_i
714
+ assert_equal '1', oo.cell('A',1)
715
+ assert_equal '1', oo.cell('B',1)
716
+ assert_equal '1', oo.cell('C',1)
693
717
 
694
- assert_equal 1, oo.cell('A',3)
695
- assert_equal 3, oo.cell('B',3)
696
- assert_equal 1, oo.cell('C',3)
718
+ # assert_equal 1, oo.cell('A',2)
719
+ # assert_equal 2, oo.cell('B',2)
720
+ # assert_equal 1, oo.cell('C',2)
721
+ # are stored as strings, not numbers
697
722
 
698
- assert_equal 'A', oo.cell('A',4)
699
- assert_equal 'A', oo.cell('B',4)
700
- assert_equal 'A', oo.cell('C',4)
723
+ assert_equal 1, oo.cell('A',2).to_i
724
+ assert_equal 2, oo.cell('B',2).to_i
725
+ assert_equal 1, oo.cell('C',2).to_i
701
726
 
702
- assert_equal '0.01', oo.cell('A',5)
703
- assert_equal '0.01', oo.cell('B',5)
704
- assert_equal '0.01', oo.cell('C',5)
727
+ assert_equal 1, oo.cell('A',3)
728
+ assert_equal 3, oo.cell('B',3)
729
+ assert_equal 1, oo.cell('C',3)
705
730
 
731
+ assert_equal 'A', oo.cell('A',4)
732
+ assert_equal 'A', oo.cell('B',4)
733
+ assert_equal 'A', oo.cell('C',4)
706
734
 
707
- # 1.0
735
+ assert_equal '0.01', oo.cell('A',5)
736
+ assert_equal '0.01', oo.cell('B',5)
737
+ assert_equal '0.01', oo.cell('C',5)
708
738
 
709
- # Cells values in row 1:
710
- assert_equal "1:string", oo.cell(1, 1)+":"+oo.celltype(1, 1).to_s
711
- assert_equal "1:string",oo.cell(1, 2)+":"+oo.celltype(1, 2).to_s
712
- assert_equal "1:string",oo.cell(1, 3)+":"+oo.celltype(1, 3).to_s
713
739
 
714
- # Cells values in row 2:
715
- assert_equal "1:string",oo.cell(2, 1)+":"+oo.celltype(2, 1).to_s
716
- assert_equal "2:string",oo.cell(2, 2)+":"+oo.celltype(2, 2).to_s
717
- assert_equal "1:string",oo.cell(2, 3)+":"+oo.celltype(2, 3).to_s
740
+ # 1.0
718
741
 
719
- # Cells values in row 3:
720
- assert_equal "1.0:float",oo.cell(3, 1).to_s+":"+oo.celltype(3, 1).to_s
721
- assert_equal "3.0:float",oo.cell(3, 2).to_s+":"+oo.celltype(3, 2).to_s
722
- assert_equal "1.0:float",oo.cell(3, 3).to_s+":"+oo.celltype(3, 3).to_s
742
+ # Cells values in row 1:
743
+ assert_equal "1:string", oo.cell(1, 1)+":"+oo.celltype(1, 1).to_s
744
+ assert_equal "1:string",oo.cell(1, 2)+":"+oo.celltype(1, 2).to_s
745
+ assert_equal "1:string",oo.cell(1, 3)+":"+oo.celltype(1, 3).to_s
723
746
 
724
- # Cells values in row 4:
725
- assert_equal "A:string",oo.cell(4, 1)+":"+oo.celltype(4, 1).to_s
726
- assert_equal "A:string",oo.cell(4, 2)+":"+oo.celltype(4, 2).to_s
727
- assert_equal "A:string",oo.cell(4, 3)+":"+oo.celltype(4, 3).to_s
747
+ # Cells values in row 2:
748
+ assert_equal "1:string",oo.cell(2, 1)+":"+oo.celltype(2, 1).to_s
749
+ assert_equal "2:string",oo.cell(2, 2)+":"+oo.celltype(2, 2).to_s
750
+ assert_equal "1:string",oo.cell(2, 3)+":"+oo.celltype(2, 3).to_s
728
751
 
729
- # Cells values in row 5:
730
- assert_equal "0.01:percentage",oo.cell(5, 1)+":"+oo.celltype(5, 1).to_s
731
- assert_equal "0.01:percentage",oo.cell(5, 2)+":"+oo.celltype(5, 2).to_s
732
- assert_equal "0.01:percentage",oo.cell(5, 3)+":"+oo.celltype(5, 3).to_s
733
- end
752
+ # Cells values in row 3:
753
+ assert_equal "1.0:float",oo.cell(3, 1).to_s+":"+oo.celltype(3, 1).to_s
754
+ assert_equal "3.0:float",oo.cell(3, 2).to_s+":"+oo.celltype(3, 2).to_s
755
+ assert_equal "1.0:float",oo.cell(3, 3).to_s+":"+oo.celltype(3, 3).to_s
734
756
 
735
- end
757
+ # Cells values in row 4:
758
+ assert_equal "A:string",oo.cell(4, 1)+":"+oo.celltype(4, 1).to_s
759
+ assert_equal "A:string",oo.cell(4, 2)+":"+oo.celltype(4, 2).to_s
760
+ assert_equal "A:string",oo.cell(4, 3)+":"+oo.celltype(4, 3).to_s
736
761
 
737
- def test_external1
738
- local_only do
739
- if File.exist?(File.join("test","external1.xls"))
740
- oo = Excel.new(File.join("test","external1.xls"))
741
- oo.default_sheet = 2
742
- assert_equal(-105.675, oo.cell('Z',5))
743
- assert_equal(41.31205555, oo.cell('AA',5))
744
- assert_equal(2218.3344, oo.cell('AB',5))
745
- end
762
+ # Cells values in row 5:
763
+ assert_equal "0.01:percentage",oo.cell(5, 1)+":"+oo.celltype(5, 1).to_s
764
+ assert_equal "0.01:percentage",oo.cell(5, 2)+":"+oo.celltype(5, 2).to_s
765
+ assert_equal "0.01:percentage",oo.cell(5, 3)+":"+oo.celltype(5, 3).to_s
746
766
  end
747
- end
748
767
 
749
- def myfunc(n)
750
- puts "#{n} Euro"
751
768
  end
752
769
 
753
770
  def test_formula
@@ -765,10 +782,10 @@ class TestRoo < Test::Unit::TestCase
765
782
  assert_equal "=[Sheet2.A1]", oo.formula('C',7)
766
783
  assert_nil oo.formula('A',6)
767
784
  assert_equal [[7, 1, "=SUM([.A1:.A6])"],
768
- [7, 2, "=SUM([.$A$1:.B6])"],
769
- [7, 3, "=[Sheet2.A1]"],
770
- [8, 2, "=SUM([.$A$1:.B7])"],
771
- ], oo.formulas
785
+ [7, 2, "=SUM([.$A$1:.B6])"],
786
+ [7, 3, "=[Sheet2.A1]"],
787
+ [8, 2, "=SUM([.$A$1:.B7])"],
788
+ ], oo.formulas
772
789
 
773
790
  after Date.new(2007,6,25) do
774
791
  # setting a cell
@@ -799,8 +816,8 @@ class TestRoo < Test::Unit::TestCase
799
816
  oo.default_sheet = oo.sheets.first
800
817
  #assert_nil oo.first_row
801
818
  assert_equal 5, oo.first_row
802
- #assert_nil oo.last_row
803
- assert_equal 10, oo.last_row
819
+ #assert_nil oo.last_row
820
+ assert_equal 10, oo.last_row
804
821
  assert_equal 3, oo.first_column
805
822
  #assert_nil oo.first_column
806
823
  assert_equal 7, oo.last_column
@@ -814,7 +831,7 @@ class TestRoo < Test::Unit::TestCase
814
831
  end
815
832
  if EXCEL
816
833
  oo = Excel.new(File.join("test","borders.xls"))
817
- p oo.sheets
834
+ p oo.sheets
818
835
  p oo.sheets[1]
819
836
  oo.default_sheet = oo.sheets[1]
820
837
  assert_equal 6, oo.first_row
@@ -825,8 +842,8 @@ p oo.sheets
825
842
  oo.default_sheet = 1 # oo.sheets.first
826
843
  #assert_nil oo.first_row
827
844
  assert_equal 5, oo.first_row
828
- #assert_nil oo.last_row
829
- assert_equal 10, oo.last_row
845
+ #assert_nil oo.last_row
846
+ assert_equal 10, oo.last_row
830
847
  assert_equal 3, oo.first_column
831
848
  #assert_nil oo.first_column
832
849
  assert_equal 7, oo.last_column
@@ -838,7 +855,7 @@ p oo.sheets
838
855
  assert_equal 5, oo.first_column
839
856
  assert_equal 9, oo.last_column
840
857
  end
841
-
858
+
842
859
  end
843
860
 
844
861
  def yaml_entry(row,col,type,value)
@@ -853,61 +870,59 @@ p oo.sheets
853
870
  assert_equal "--- \n"+yaml_entry(8,3,"string","thisisc8"), oo.to_yaml({}, 8,3,8,3)
854
871
  assert_equal "--- \n"+yaml_entry(12,3,"float",43.0), oo.to_yaml({}, 12,3,12,3)
855
872
  assert_equal \
856
- "--- \n"+yaml_entry(12,3,"float",43.0) +
857
- yaml_entry(12,4,"float",44.0) +
858
- yaml_entry(12,5,"float",45.0), oo.to_yaml({}, 12,3,12)
873
+ "--- \n"+yaml_entry(12,3,"float",43.0) +
874
+ yaml_entry(12,4,"float",44.0) +
875
+ yaml_entry(12,5,"float",45.0), oo.to_yaml({}, 12,3,12)
859
876
  assert_equal \
860
- "--- \n"+yaml_entry(12,3,"float",43.0)+
861
- yaml_entry(12,4,"float",44.0)+
862
- yaml_entry(12,5,"float",45.0)+
863
- yaml_entry(15,3,"float",43.0)+
864
- yaml_entry(15,4,"float",44.0)+
865
- yaml_entry(15,5,"float",45.0)+
866
- yaml_entry(16,3,"string","dreiundvierzig")+
867
- yaml_entry(16,4,"string","vierundvierzig")+
868
- yaml_entry(16,5,"string","fuenfundvierzig"), oo.to_yaml({}, 12,3)
869
- #example: puts oo.to_yaml({}, 12,3)
870
- #example: puts oo.to_yaml({"probe" => "bodenproben_2007-06-30"}, 12,3)
877
+ "--- \n"+yaml_entry(12,3,"float",43.0)+
878
+ yaml_entry(12,4,"float",44.0)+
879
+ yaml_entry(12,5,"float",45.0)+
880
+ yaml_entry(15,3,"float",43.0)+
881
+ yaml_entry(15,4,"float",44.0)+
882
+ yaml_entry(15,5,"float",45.0)+
883
+ yaml_entry(16,3,"string","dreiundvierzig")+
884
+ yaml_entry(16,4,"string","vierundvierzig")+
885
+ yaml_entry(16,5,"string","fuenfundvierzig"), oo.to_yaml({}, 12,3)
886
+ #example: puts oo.to_yaml({}, 12,3)
887
+ #example: puts oo.to_yaml({"probe" => "bodenproben_2007-06-30"}, 12,3)
871
888
  end
872
889
  if EXCEL
873
890
  oo = Excel.new(File.join("test","numbers1.xls"))
874
- oo.default_sheet = 1
891
+ oo.default_sheet = 1
875
892
  assert_equal "--- \n"+yaml_entry(5,1,"date","1961-11-21"), oo.to_yaml({}, 5,1,5,1)
876
893
  assert_equal "--- \n"+yaml_entry(8,3,"string","thisisc8"), oo.to_yaml({}, 8,3,8,3)
877
894
  assert_equal "--- \n"+yaml_entry(12,3,"float",43.0), oo.to_yaml({}, 12,3,12,3)
878
895
  assert_equal \
879
- "--- \n"+yaml_entry(12,3,"float",43.0) +
880
- yaml_entry(12,4,"float",44.0) +
881
- yaml_entry(12,5,"float",45.0), oo.to_yaml({}, 12,3,12)
896
+ "--- \n"+yaml_entry(12,3,"float",43.0) +
897
+ yaml_entry(12,4,"float",44.0) +
898
+ yaml_entry(12,5,"float",45.0), oo.to_yaml({}, 12,3,12)
882
899
  assert_equal \
883
- "--- \n"+yaml_entry(12,3,"float",43.0)+
884
- yaml_entry(12,4,"float",44.0)+
885
- yaml_entry(12,5,"float",45.0)+
886
- yaml_entry(15,3,"float",43.0)+
887
- yaml_entry(15,4,"float",44.0)+
888
- yaml_entry(15,5,"float",45.0)+
889
- yaml_entry(16,3,"string","dreiundvierzig")+
890
- yaml_entry(16,4,"string","vierundvierzig")+
891
- yaml_entry(16,5,"string","fuenfundvierzig"), oo.to_yaml({}, 12,3)
892
- end
893
- end
894
-
895
- if false
896
- def test_soap_server
897
- #threads = []
898
- #threads << Thread.new("serverthread") do
899
- fork do
900
- p "serverthread started"
901
- puts "in child, pid = #$$"
902
- puts `/usr/bin/ruby rooserver.rb`
903
- p "serverthread finished"
904
- end
905
- #threads << Thread.new("clientthread") do
900
+ "--- \n"+yaml_entry(12,3,"float",43.0)+
901
+ yaml_entry(12,4,"float",44.0)+
902
+ yaml_entry(12,5,"float",45.0)+
903
+ yaml_entry(15,3,"float",43.0)+
904
+ yaml_entry(15,4,"float",44.0)+
905
+ yaml_entry(15,5,"float",45.0)+
906
+ yaml_entry(16,3,"string","dreiundvierzig")+
907
+ yaml_entry(16,4,"string","vierundvierzig")+
908
+ yaml_entry(16,5,"string","fuenfundvierzig"), oo.to_yaml({}, 12,3)
909
+ end
910
+ end
911
+
912
+ if false
913
+ def test_soap_server
914
+ #threads = []
915
+ #threads << Thread.new("serverthread") do
916
+ fork do
917
+ p "serverthread started"
918
+ puts "in child, pid = #$$"
919
+ puts `/usr/bin/ruby rooserver.rb`
920
+ p "serverthread finished"
921
+ end
922
+ #threads << Thread.new("clientthread") do
906
923
  p "clientthread started"
907
- sleep 10
924
+ sleep 10
908
925
  proxy = SOAP::RPC::Driver.new("http://localhost:12321","spreadsheetserver")
909
- #"http://localhost:2222")
910
- #"http://pragprog.com/InterestCalc")
911
926
  proxy.add_method('cell','row','col')
912
927
  proxy.add_method('officeversion')
913
928
  proxy.add_method('last_row')
@@ -917,9 +932,9 @@ if false
917
932
  proxy.add_method('sheets')
918
933
  proxy.add_method('set_default_sheet','s')
919
934
  proxy.add_method('ferien_fuer_region', 'region')
920
-
935
+
921
936
  sheets = proxy.sheets
922
- p sheets
937
+ p sheets
923
938
  proxy.set_default_sheet(sheets.first)
924
939
 
925
940
  assert_equal 1, proxy.first_row
@@ -930,14 +945,14 @@ p sheets
930
945
  assert_equal 43, proxy.cell('F',12)
931
946
  assert_equal "1.0", proxy.officeversion
932
947
  p "clientthread finished"
933
- #end
934
- #threads.each {|t| t.join }
935
- puts "fertig"
936
- Process.kill("INT",pid)
937
- pid=Process.wait
938
- puts "child terminated, pid= #{pid}, status= #{$?.exitstatus}"
939
- end
940
- end # false
948
+ #end
949
+ #threads.each {|t| t.join }
950
+ puts "fertig"
951
+ Process.kill("INT",pid)
952
+ pid=Process.wait
953
+ puts "child terminated, pid= #{pid}, status= #{$?.exitstatus}"
954
+ end
955
+ end # false
941
956
 
942
957
  def split_coord(s)
943
958
  letter = ""
@@ -977,15 +992,15 @@ end # false
977
992
  #def test_dsl
978
993
  # s = Openoffice.new(File.join("test","numbers1.ods"))
979
994
  # s.default_sheet = s.sheets.first
980
- #
981
- # s.set 'a',1, 5
982
- # s.set 'b',1, 3
983
- # s.set 'c',1, 7
984
- # s.set('a',2, s.cell('a',1)+s.cell('b',1))
985
- # assert_equal 8, s.cell('a',2)
986
- #
987
- # assert_equal 15, sum(s,'A1:C1')
988
- # end
995
+ #
996
+ # s.set 'a',1, 5
997
+ # s.set 'b',1, 3
998
+ # s.set 'c',1, 7
999
+ # s.set('a',2, s.cell('a',1)+s.cell('b',1))
1000
+ # assert_equal 8, s.cell('a',2)
1001
+ #
1002
+ # assert_equal 15, sum(s,'A1:C1')
1003
+ # end
989
1004
 
990
1005
  #def test_create_spreadsheet1
991
1006
  # name=File.join('test','createdspreadsheet.ods')
@@ -1002,7 +1017,7 @@ end # false
1002
1017
  # s.set 'b',1,43
1003
1018
  # s.set 'c',1,44
1004
1019
  # s.save
1005
- #
1020
+ #
1006
1021
  # #after Date.new(2007,7,3) do
1007
1022
  # # t = Openoffice.new(File.join("test","createdspreadsheet.ods"))
1008
1023
  # # assert_equal 42, t.cell(1,'a')
@@ -1011,5 +1026,48 @@ end # false
1011
1026
  # #end
1012
1027
  #end
1013
1028
 
1029
+ def test_only_one_sheet
1030
+ if OPENOFFICE
1031
+ oo = Openoffice.new(File.join("test","only_one_sheet.ods"))
1032
+ # oo.default_sheet = oo.sheets.first
1033
+ assert_equal 42, oo.cell('B',4)
1034
+ assert_equal 43, oo.cell('C',4)
1035
+ assert_equal 44, oo.cell('D',4)
1036
+ oo.default_sheet = oo.sheets.first
1037
+ assert_equal 42, oo.cell('B',4)
1038
+ assert_equal 43, oo.cell('C',4)
1039
+ assert_equal 44, oo.cell('D',4)
1040
+ end
1041
+ if EXCEL
1042
+ oo = Excel.new(File.join("test","only_one_sheet.xls"))
1043
+ # oo.default_sheet = oo.sheets.first
1044
+ assert_equal 42, oo.cell('B',4)
1045
+ assert_equal 43, oo.cell('C',4)
1046
+ assert_equal 44, oo.cell('D',4)
1047
+ oo.default_sheet = oo.sheets.first
1048
+ assert_equal 42, oo.cell('B',4)
1049
+ assert_equal 43, oo.cell('C',4)
1050
+ assert_equal 44, oo.cell('D',4)
1051
+ end
1052
+ if GOOGLE
1053
+ after Date.new(2007,8,30) do
1054
+ raise "need to write test for GOOGLE"
1055
+ end
1056
+ end
1014
1057
 
1058
+ end
1059
+
1060
+ def test_open_from_uri_and_zipped
1061
+ url = 'http://stiny-leonhard.de/bode-v1.xls.zip'
1062
+ excel = Excel.new(url, :zip)
1063
+ assert_equal 'ist "e" im Nenner von H(s)', excel.cell('b', 5)
1064
+ excel.remove_tmp # don't forget to remove the temporary files
1065
+ end
1066
+
1067
+ def test_zipped
1068
+ excel = Excel.new(File.join("test","bode-v1.xls.zip"), :zip)
1069
+ assert excel
1070
+ assert_equal 'ist "e" im Nenner von H(s)', excel.cell('b', 5)
1071
+ excel.remove_tmp # don't forget to remove the temporary files
1072
+ end
1015
1073
  end # class