roo 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/Manifest.txt +7 -1
- data/Rakefile +1 -2
- data/base64include.rb +149 -0
- data/examples/roo_soap_client.rb +53 -0
- data/examples/roo_soap_server.rb +29 -0
- data/lib/roo.rb +1 -1
- data/lib/roo/excel.rb +40 -22
- data/lib/roo/openoffice.rb +51 -17
- data/lib/roo/version.rb +2 -2
- data/test/borders.ods +0 -0
- data/test/borders.xls +0 -0
- data/test/formula.ods +0 -0
- data/test/formula.xls +0 -0
- data/test/test_roo.rb +265 -120
- data/website/index.html +55 -12
- data/website/index.txt +38 -10
- data/website/stylesheets/screen.css +2 -1
- metadata +10 -13
- data/lib/roo/spreadsheetparser.rb +0 -92
data/lib/roo/version.rb
CHANGED
data/test/borders.ods
ADDED
Binary file
|
data/test/borders.xls
ADDED
Binary file
|
data/test/formula.ods
ADDED
Binary file
|
data/test/formula.xls
ADDED
Binary file
|
data/test/test_roo.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
#require 'soap/rpc/driver'
|
3
|
+
require 'fileutils'
|
4
|
+
include FileUtils
|
2
5
|
|
3
6
|
class TestRoo < Test::Unit::TestCase
|
4
7
|
|
@@ -6,8 +9,29 @@ class TestRoo < Test::Unit::TestCase
|
|
6
9
|
EXCEL = true # do Excel Tests?
|
7
10
|
GOOGLE = false # do Google-Spreadsheet Tests?
|
8
11
|
|
9
|
-
OPENOFFICEWRITE = false # experimental: write access with OO-
|
12
|
+
OPENOFFICEWRITE = false # experimental: write access with OO-Documents
|
10
13
|
|
14
|
+
# helper method
|
15
|
+
def local_only
|
16
|
+
if ENV["roo_local"] == "thomas-p"
|
17
|
+
yield
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# helper method
|
22
|
+
def after(d)
|
23
|
+
if DateTime.now > d
|
24
|
+
yield
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# helper method
|
29
|
+
def before(d)
|
30
|
+
if DateTime.now <= d
|
31
|
+
yield
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
11
35
|
def setup
|
12
36
|
if GOOGLE
|
13
37
|
@goo = Google.new(ENV['GOOGLE_MAIL'],
|
@@ -28,18 +52,16 @@ class TestRoo < Test::Unit::TestCase
|
|
28
52
|
end
|
29
53
|
|
30
54
|
def test_sheets
|
31
|
-
|
32
|
-
|
33
|
-
|
55
|
+
if OPENOFFICE
|
56
|
+
oo = Openoffice.new(File.join("test","numbers1.ods"))
|
57
|
+
assert_equal ["Tabelle1","Name of Sheet 2","Sheet3","Sheet4","Sheet5"], oo.sheets
|
58
|
+
end
|
34
59
|
if EXCEL
|
35
|
-
if DateTime.now > Date.new(2007,6,30)
|
36
60
|
oo = Excel.new(File.join("test","numbers1.xls"))
|
37
|
-
assert_equal ["Tabelle1","Name of Sheet 2","Sheet3"], oo.sheets
|
38
|
-
end
|
61
|
+
assert_equal ["Tabelle1","Name of Sheet 2","Sheet3","Sheet4","Sheet5"], oo.sheets
|
39
62
|
end
|
40
|
-
#-- Google
|
41
63
|
if GOOGLE
|
42
|
-
|
64
|
+
after Date.new(2007,6,10) do
|
43
65
|
assert_equal "Testspreadsheet Roo", @goo.title
|
44
66
|
end
|
45
67
|
assert_equal ["Sheet eins","Sheet zwei","Sheet drei"], @goo.sheets
|
@@ -47,6 +69,7 @@ end
|
|
47
69
|
end
|
48
70
|
|
49
71
|
def test_cell
|
72
|
+
if OPENOFFICE
|
50
73
|
oo = Openoffice.new(File.join("test","numbers1.ods"))
|
51
74
|
oo.default_sheet = oo.sheets.first
|
52
75
|
assert_equal 1, oo.cell(1,1)
|
@@ -59,9 +82,11 @@ end
|
|
59
82
|
assert_equal 8, oo.cell(2,4)
|
60
83
|
assert_equal 9, oo.cell(2,5)
|
61
84
|
assert_equal "test", oo.cell(2,6)
|
62
|
-
assert_equal "string", oo.celltype(2,6)
|
85
|
+
# assert_equal "string", oo.celltype(2,6)
|
86
|
+
assert_equal :string, oo.celltype(2,6)
|
63
87
|
assert_equal 11, oo.cell(2,7)
|
64
|
-
assert_equal "float", oo.celltype(2,7)
|
88
|
+
# assert_equal "float", oo.celltype(2,7)
|
89
|
+
assert_equal :float, oo.celltype(2,7)
|
65
90
|
|
66
91
|
assert_equal 10, oo.cell(4,1)
|
67
92
|
assert_equal 11, oo.cell(4,2)
|
@@ -75,13 +100,15 @@ end
|
|
75
100
|
assert_equal 13, oo.cell(4,'D')
|
76
101
|
assert_equal 14, oo.cell(4,'E')
|
77
102
|
|
78
|
-
assert_equal "date", oo.celltype(5,1)
|
103
|
+
# assert_equal "date", oo.celltype(5,1)
|
104
|
+
assert_equal :date, oo.celltype(5,1)
|
79
105
|
assert_equal Date.new(1961,11,21), oo.cell(5,1)
|
80
106
|
assert_equal "1961-11-21", oo.cell(5,1).to_s
|
107
|
+
end
|
81
108
|
|
82
109
|
if EXCEL
|
83
110
|
oo = Excel.new(File.join("test","numbers1.xls"))
|
84
|
-
oo.default_sheet =
|
111
|
+
oo.default_sheet = oo.sheets.first
|
85
112
|
assert_equal 1, oo.cell(1,1)
|
86
113
|
assert_equal 2, oo.cell(1,2)
|
87
114
|
assert_equal 3, oo.cell(1,3)
|
@@ -92,9 +119,11 @@ end
|
|
92
119
|
assert_equal 8, oo.cell(2,4)
|
93
120
|
assert_equal 9, oo.cell(2,5)
|
94
121
|
assert_equal "test", oo.cell(2,6)
|
95
|
-
assert_equal "string", oo.celltype(2,6)
|
122
|
+
# assert_equal "string", oo.celltype(2,6)
|
123
|
+
assert_equal :string, oo.celltype(2,6)
|
96
124
|
assert_equal 11, oo.cell(2,7)
|
97
|
-
assert_equal "float", oo.celltype(2,7)
|
125
|
+
# assert_equal "float", oo.celltype(2,7)
|
126
|
+
assert_equal :float, oo.celltype(2,7)
|
98
127
|
|
99
128
|
assert_equal 10, oo.cell(4,1)
|
100
129
|
assert_equal 11, oo.cell(4,2)
|
@@ -108,7 +137,8 @@ end
|
|
108
137
|
assert_equal 13, oo.cell(4,'D')
|
109
138
|
assert_equal 14, oo.cell(4,'E')
|
110
139
|
|
111
|
-
assert_equal "date", oo.celltype(5,1)
|
140
|
+
# assert_equal "date", oo.celltype(5,1)
|
141
|
+
assert_equal :date, oo.celltype(5,1)
|
112
142
|
assert_equal Date.new(1961,11,21), oo.cell(5,1)
|
113
143
|
assert_equal "1961-11-21", oo.cell(5,1).to_s
|
114
144
|
end
|
@@ -125,10 +155,12 @@ end
|
|
125
155
|
assert_equal 8, @goo.cell(2,4).to_i
|
126
156
|
assert_equal 9, @goo.cell(2,5).to_i
|
127
157
|
assert_equal "test", @goo.cell(2,6)
|
128
|
-
assert_equal "string", @goo.celltype(2,6)
|
158
|
+
# assert_equal "string", @goo.celltype(2,6)
|
159
|
+
assert_equal :string, @goo.celltype(2,6)
|
129
160
|
assert_equal 11, @goo.cell(2,7).to_i
|
130
|
-
|
131
|
-
assert_equal "float", @goo.celltype(2,7)
|
161
|
+
after Date.new(2007,6,15) do
|
162
|
+
# assert_equal "float", @goo.celltype(2,7)
|
163
|
+
assert_equal :float, @goo.celltype(2,7)
|
132
164
|
end
|
133
165
|
|
134
166
|
assert_equal 10, @goo.cell(4,1).to_i
|
@@ -143,45 +175,62 @@ end
|
|
143
175
|
assert_equal 13, @goo.cell(4,'D').to_i
|
144
176
|
assert_equal 14, @goo.cell(4,'E').to_i
|
145
177
|
|
146
|
-
|
147
|
-
assert_equal "date", @goo.celltype(5,1)
|
178
|
+
after Date.new(2007,6,15) do
|
179
|
+
# assert_equal "date", @goo.celltype(5,1)
|
180
|
+
assert_equal :date, @goo.celltype(5,1)
|
148
181
|
end
|
149
|
-
|
182
|
+
after Date.new(2007,6,15) do
|
150
183
|
assert_equal Date.new(1961,11,21), @goo.cell(5,1)
|
151
184
|
assert_equal "1961-11-21", @goo.cell(5,1).to_s
|
152
|
-
|
185
|
+
end
|
186
|
+
before Date.new(2007,6,15) do
|
153
187
|
assert_equal "21/11/1961", @goo.cell(5,1)
|
154
188
|
end
|
155
189
|
end # GOOGLE
|
156
190
|
end
|
157
191
|
|
158
192
|
def test_cell_address
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
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
|
175
217
|
|
176
218
|
if EXCEL
|
177
219
|
oo = Excel.new(File.join("test","numbers1.xls"))
|
178
|
-
oo.default_sheet =
|
220
|
+
oo.default_sheet = oo.sheets.first
|
179
221
|
assert_equal "tata", oo.cell(6,1)
|
180
222
|
assert_equal "tata", oo.cell(6,'A')
|
181
223
|
assert_equal "tata", oo.cell('A',6)
|
182
224
|
assert_equal "tata", oo.cell(6,'a')
|
183
225
|
assert_equal "tata", oo.cell('a',6)
|
184
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
|
+
|
185
234
|
assert_equal "thisisc8", oo.cell(8,3)
|
186
235
|
assert_equal "thisisc8", oo.cell(8,'C')
|
187
236
|
assert_equal "thisisc8", oo.cell('C',8)
|
@@ -222,14 +271,14 @@ end
|
|
222
271
|
# excel does not have a officeversion
|
223
272
|
# is there a similar version number which ist considerable
|
224
273
|
#-- Excel
|
225
|
-
#
|
274
|
+
#after Date.new(2007,6,15) do
|
226
275
|
# oo = Excel.new(File.join("test","numbers1.xls"))
|
227
276
|
# assert_equal "1.0", oo.officeversion
|
228
277
|
#end
|
229
278
|
end
|
230
279
|
#-- Google
|
231
280
|
if GOOGLE
|
232
|
-
|
281
|
+
after Date.new(2007,6,15) do
|
233
282
|
assert_equal "1.0", @goo.officeversion
|
234
283
|
end
|
235
284
|
end
|
@@ -254,7 +303,7 @@ end
|
|
254
303
|
if EXCEL
|
255
304
|
#-- Excel
|
256
305
|
oo = Excel.new(File.join("test","numbers1.xls"))
|
257
|
-
oo.default_sheet =
|
306
|
+
oo.default_sheet = oo.sheets.first
|
258
307
|
assert_equal 41, oo.cell('a',12)
|
259
308
|
assert_equal 42, oo.cell('b',12)
|
260
309
|
assert_equal 43, oo.cell('c',12)
|
@@ -272,7 +321,7 @@ end
|
|
272
321
|
"vierundvierzig",
|
273
322
|
"fuenfundvierzig"], oo.row(16)
|
274
323
|
end
|
275
|
-
|
324
|
+
after Date.new(2007,6,17) do
|
276
325
|
#-- GOOGLE
|
277
326
|
if GOOGLE
|
278
327
|
oo = Google.new(File.join("test","numbers1.xls"))
|
@@ -299,18 +348,17 @@ end
|
|
299
348
|
end
|
300
349
|
|
301
350
|
def test_last_row
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
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
|
306
356
|
if EXCEL
|
307
|
-
#-- Excel
|
308
357
|
oo = Excel.new(File.join("test","numbers1.xls"))
|
309
|
-
oo.default_sheet =
|
358
|
+
oo.default_sheet = oo.sheets.first
|
310
359
|
assert_equal 18, oo.last_row
|
311
360
|
end
|
312
361
|
if GOOGLE
|
313
|
-
#-- Google
|
314
362
|
@goo.default_sheet = @goo.sheets.first
|
315
363
|
assert_equal 18, @goo.last_row
|
316
364
|
assert_equal "xxx", @goo.to_s, @goo.to_s
|
@@ -318,14 +366,15 @@ end
|
|
318
366
|
end
|
319
367
|
|
320
368
|
def test_last_column
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
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
|
325
374
|
if EXCEL
|
326
375
|
#-- Excel
|
327
376
|
oo = Excel.new(File.join("test","numbers1.xls"))
|
328
|
-
oo.default_sheet =
|
377
|
+
oo.default_sheet = oo.sheets.first
|
329
378
|
assert_equal 7, oo.last_column
|
330
379
|
end
|
331
380
|
if GOOGLE
|
@@ -408,17 +457,16 @@ end
|
|
408
457
|
end
|
409
458
|
|
410
459
|
def test_sheetname
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
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
|
418
467
|
oo = Excel.new(File.join("test","numbers1.xls"))
|
419
468
|
oo.default_sheet = "Name of Sheet 2"
|
420
469
|
assert_equal 'I am sheet 2', oo.cell('C',5)
|
421
|
-
end
|
422
470
|
end
|
423
471
|
end
|
424
472
|
|
@@ -471,9 +519,11 @@ end
|
|
471
519
|
def test_argument_error
|
472
520
|
if EXCEL
|
473
521
|
oo = Excel.new(File.join("test","numbers1.xls"))
|
474
|
-
|
475
|
-
|
476
|
-
|
522
|
+
before Date.new(2007,7,20) do
|
523
|
+
assert_raise(ArgumentError) {
|
524
|
+
oo.default_sheet = "first sheet"
|
525
|
+
}
|
526
|
+
end
|
477
527
|
assert_nothing_raised(ArgumentError) {
|
478
528
|
oo.default_sheet = 1
|
479
529
|
}
|
@@ -508,7 +558,8 @@ end
|
|
508
558
|
oo.first_row.upto(oo.last_row) {|y|
|
509
559
|
oo.first_column.upto(oo.last_column) {|x|
|
510
560
|
unless oo.empty?(y,x)
|
511
|
-
oo.set(y, x, oo.cell(y,x) + 7) if oo.celltype(y,x) == "float"
|
561
|
+
# oo.set(y, x, oo.cell(y,x) + 7) if oo.celltype(y,x) == "float"
|
562
|
+
oo.set(y, x, oo.cell(y,x) + 7) if oo.celltype(y,x) == :float
|
512
563
|
end
|
513
564
|
}
|
514
565
|
}
|
@@ -623,6 +674,7 @@ end
|
|
623
674
|
end
|
624
675
|
|
625
676
|
def test_italo_table
|
677
|
+
local_only do
|
626
678
|
oo = Openoffice.new(File.join("test","simple_spreadsheet_from_italo.ods"))
|
627
679
|
oo.default_sheet = oo.sheets.first
|
628
680
|
|
@@ -655,34 +707,35 @@ end
|
|
655
707
|
# 1.0
|
656
708
|
|
657
709
|
# Cells values in row 1:
|
658
|
-
assert_equal "1:string", oo.cell(1, 1)+":"+oo.celltype(1, 1)
|
659
|
-
assert_equal "1:string",oo.cell(1, 2)+":"+oo.celltype(1, 2)
|
660
|
-
assert_equal "1:string",oo.cell(1, 3)+":"+oo.celltype(1, 3)
|
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
|
661
713
|
|
662
714
|
# Cells values in row 2:
|
663
|
-
assert_equal "1:string",oo.cell(2, 1)+":"+oo.celltype(2, 1)
|
664
|
-
assert_equal "2:string",oo.cell(2, 2)+":"+oo.celltype(2, 2)
|
665
|
-
assert_equal "1:string",oo.cell(2, 3)+":"+oo.celltype(2, 3)
|
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
|
666
718
|
|
667
719
|
# Cells values in row 3:
|
668
|
-
assert_equal "1.0:float",oo.cell(3, 1).to_s+":"+oo.celltype(3, 1)
|
669
|
-
assert_equal "3.0:float",oo.cell(3, 2).to_s+":"+oo.celltype(3, 2)
|
670
|
-
assert_equal "1.0:float",oo.cell(3, 3).to_s+":"+oo.celltype(3, 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
|
671
723
|
|
672
724
|
# Cells values in row 4:
|
673
|
-
assert_equal "A:string",oo.cell(4, 1)+":"+oo.celltype(4, 1)
|
674
|
-
assert_equal "A:string",oo.cell(4, 2)+":"+oo.celltype(4, 2)
|
675
|
-
assert_equal "A:string",oo.cell(4, 3)+":"+oo.celltype(4, 3)
|
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
|
676
728
|
|
677
729
|
# Cells values in row 5:
|
678
|
-
assert_equal "0.01:percentage",oo.cell(5, 1)+":"+oo.celltype(5, 1)
|
679
|
-
assert_equal "0.01:percentage",oo.cell(5, 2)+":"+oo.celltype(5, 2)
|
680
|
-
assert_equal "0.01:percentage",oo.cell(5, 3)+":"+oo.celltype(5, 3)
|
681
|
-
|
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
|
682
734
|
|
683
735
|
end
|
684
736
|
|
685
737
|
def test_external1
|
738
|
+
local_only do
|
686
739
|
if File.exist?(File.join("test","external1.xls"))
|
687
740
|
oo = Excel.new(File.join("test","external1.xls"))
|
688
741
|
oo.default_sheet = 2
|
@@ -690,6 +743,7 @@ end
|
|
690
743
|
assert_equal(41.31205555, oo.cell('AA',5))
|
691
744
|
assert_equal(2218.3344, oo.cell('AB',5))
|
692
745
|
end
|
746
|
+
end
|
693
747
|
end
|
694
748
|
|
695
749
|
def myfunc(n)
|
@@ -716,7 +770,7 @@ end
|
|
716
770
|
[8, 2, "=SUM([.$A$1:.B7])"],
|
717
771
|
], oo.formulas
|
718
772
|
|
719
|
-
|
773
|
+
after Date.new(2007,6,25) do
|
720
774
|
# setting a cell
|
721
775
|
oo.set('A',15, 41)
|
722
776
|
assert_equal 41, oo.cell('A',15)
|
@@ -725,31 +779,10 @@ end
|
|
725
779
|
oo.set('A',17, 42.5)
|
726
780
|
assert_equal 42.5, oo.cell('A',17)
|
727
781
|
end
|
728
|
-
|
729
|
-
|
730
|
-
end
|
731
|
-
|
732
|
-
oo = Openoffice.new(File.join("test","external1.ods"))
|
733
|
-
# each spreadsheet, each row, each column
|
734
|
-
oo.sheets.each {|sheet|
|
735
|
-
oo.default_sheet = sheet
|
736
|
-
if oo.first_row
|
737
|
-
oo.first_row.upto(oo.last_row) do |row|
|
738
|
-
oo.first_column.upto(oo.last_column) do |col|
|
739
|
-
value = oo.cell(row,col)
|
740
|
-
# is it a formula?
|
741
|
-
if oo.formula?(row,col)
|
742
|
-
# formula
|
743
|
-
puts oo.formula(row,col)
|
744
|
-
# value
|
745
|
-
puts value if value
|
746
|
-
else
|
747
|
-
puts value if value
|
748
|
-
end
|
749
|
-
end
|
750
|
-
end
|
751
|
-
end
|
752
|
-
}
|
782
|
+
#after Date.new(2007,7,30) do
|
783
|
+
# assert_equal 21, oo.solve('a',7)
|
784
|
+
#end
|
785
|
+
|
753
786
|
end
|
754
787
|
end
|
755
788
|
|
@@ -781,7 +814,9 @@ end
|
|
781
814
|
end
|
782
815
|
if EXCEL
|
783
816
|
oo = Excel.new(File.join("test","borders.xls"))
|
784
|
-
|
817
|
+
p oo.sheets
|
818
|
+
p oo.sheets[1]
|
819
|
+
oo.default_sheet = oo.sheets[1]
|
785
820
|
assert_equal 6, oo.first_row
|
786
821
|
assert_equal 11, oo.last_row
|
787
822
|
assert_equal 4, oo.first_column
|
@@ -831,6 +866,8 @@ end
|
|
831
866
|
yaml_entry(16,3,"string","dreiundvierzig")+
|
832
867
|
yaml_entry(16,4,"string","vierundvierzig")+
|
833
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)
|
834
871
|
end
|
835
872
|
if EXCEL
|
836
873
|
oo = Excel.new(File.join("test","numbers1.xls"))
|
@@ -855,16 +892,124 @@ end
|
|
855
892
|
end
|
856
893
|
end
|
857
894
|
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
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
|
906
|
+
p "clientthread started"
|
907
|
+
sleep 10
|
908
|
+
proxy = SOAP::RPC::Driver.new("http://localhost:12321","spreadsheetserver")
|
909
|
+
#"http://localhost:2222")
|
910
|
+
#"http://pragprog.com/InterestCalc")
|
911
|
+
proxy.add_method('cell','row','col')
|
912
|
+
proxy.add_method('officeversion')
|
913
|
+
proxy.add_method('last_row')
|
914
|
+
proxy.add_method('last_column')
|
915
|
+
proxy.add_method('first_row')
|
916
|
+
proxy.add_method('first_column')
|
917
|
+
proxy.add_method('sheets')
|
918
|
+
proxy.add_method('set_default_sheet','s')
|
919
|
+
proxy.add_method('ferien_fuer_region', 'region')
|
920
|
+
|
921
|
+
sheets = proxy.sheets
|
922
|
+
p sheets
|
923
|
+
proxy.set_default_sheet(sheets.first)
|
924
|
+
|
925
|
+
assert_equal 1, proxy.first_row
|
926
|
+
assert_equal 1, proxy.first_column
|
927
|
+
assert_equal 187, proxy.last_row
|
928
|
+
assert_equal 7, proxy.last_column
|
929
|
+
assert_equal 42, proxy.cell('C',8)
|
930
|
+
assert_equal 43, proxy.cell('F',12)
|
931
|
+
assert_equal "1.0", proxy.officeversion
|
932
|
+
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
|
941
|
+
|
942
|
+
def split_coord(s)
|
943
|
+
letter = ""
|
944
|
+
number = 0
|
945
|
+
i = 0
|
946
|
+
while i<s.length and "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".include?(s[i,1])
|
947
|
+
letter += s[i,1]
|
948
|
+
i+=1
|
949
|
+
end
|
950
|
+
while i<s.length and "01234567890".include?(s[i,1])
|
951
|
+
number = number*10 + s[i,1].to_i
|
952
|
+
i+=1
|
867
953
|
end
|
954
|
+
if letter=="" or number==0
|
955
|
+
raise ArgumentError
|
956
|
+
end
|
957
|
+
return letter,number
|
868
958
|
end
|
869
959
|
|
960
|
+
#def sum(s,expression)
|
961
|
+
# arg = expression.split(':')
|
962
|
+
# b,z = split_coord(arg[0])
|
963
|
+
# first_row = z
|
964
|
+
# first_col = Openoffice.letter_to_number(b)
|
965
|
+
# b,z = split_coord(arg[1])
|
966
|
+
# last_row = z
|
967
|
+
# last_col = Openoffice.letter_to_number(b)
|
968
|
+
# result = 0
|
969
|
+
# first_row.upto(last_row) {|row|
|
970
|
+
# first_col.upto(last_col) {|col|
|
971
|
+
# result = result + s.cell(row,col)
|
972
|
+
# }
|
973
|
+
# }
|
974
|
+
# result
|
975
|
+
#end
|
976
|
+
|
977
|
+
#def test_dsl
|
978
|
+
# s = Openoffice.new(File.join("test","numbers1.ods"))
|
979
|
+
# 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
|
989
|
+
|
990
|
+
#def test_create_spreadsheet1
|
991
|
+
# name=File.join('test','createdspreadsheet.ods')
|
992
|
+
# rm(name) if File.exists?(File.join('test','createdspreadsheet.ods'))
|
993
|
+
# # anlegen, falls noch nicht existierend
|
994
|
+
# s = Openoffice.new(name,true)
|
995
|
+
# assert File.exists?(name)
|
996
|
+
#end
|
997
|
+
|
998
|
+
#def test_create_spreadsheet2
|
999
|
+
# # anlegen, falls noch nicht existierend
|
1000
|
+
# s = Openoffice.new(File.join("test","createdspreadsheet.ods"),true)
|
1001
|
+
# s.set 'a',1,42
|
1002
|
+
# s.set 'b',1,43
|
1003
|
+
# s.set 'c',1,44
|
1004
|
+
# s.save
|
1005
|
+
#
|
1006
|
+
# #after Date.new(2007,7,3) do
|
1007
|
+
# # t = Openoffice.new(File.join("test","createdspreadsheet.ods"))
|
1008
|
+
# # assert_equal 42, t.cell(1,'a')
|
1009
|
+
# # assert_equal 43, t.cell('b',1)
|
1010
|
+
# # assert_equal 44, t.cell('c',3)
|
1011
|
+
# #end
|
1012
|
+
#end
|
1013
|
+
|
1014
|
+
|
870
1015
|
end # class
|