roo 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +8 -0
- data/lib/roo/excel.rb +15 -3
- data/lib/roo/openoffice.rb +7 -1
- data/lib/roo/version.rb +1 -1
- data/test/numbers1.ods +0 -0
- data/test/numbers1.xls +0 -0
- data/test/test_roo.rb +84 -23
- data/website/index.html +1 -1
- metadata +1 -1
data/History.txt
CHANGED
data/lib/roo/excel.rb
CHANGED
@@ -16,7 +16,7 @@ class Excel < Openoffice
|
|
16
16
|
else
|
17
17
|
#worksheet = @workbook.worksheet(0)
|
18
18
|
# p @workbook
|
19
|
-
p @workbook.worksheet(0)
|
19
|
+
# p @workbook.worksheet(0)
|
20
20
|
["aaa","bbb","ccc"]
|
21
21
|
end
|
22
22
|
end
|
@@ -80,8 +80,20 @@ class Excel < Openoffice
|
|
80
80
|
|
81
81
|
def row(rownumber)
|
82
82
|
worksheet = @workbook.worksheet(@default_sheet)
|
83
|
-
|
84
|
-
|
83
|
+
therow = worksheet.row(rownumber-1)
|
84
|
+
result = []
|
85
|
+
therow.each {|cell|
|
86
|
+
case cell.type
|
87
|
+
when :numeric then result << cell.to_i
|
88
|
+
when :text then result << cell.to_s('latin1')
|
89
|
+
when :date then result << cell.date
|
90
|
+
else
|
91
|
+
return result << cell.to_s
|
92
|
+
end
|
93
|
+
|
94
|
+
#result << cell.value
|
95
|
+
}
|
96
|
+
return result
|
85
97
|
end
|
86
98
|
|
87
99
|
def first_column
|
data/lib/roo/openoffice.rb
CHANGED
@@ -126,14 +126,20 @@ class Openoffice
|
|
126
126
|
def row(rownumber)
|
127
127
|
read_cells unless @cells_read
|
128
128
|
result = []
|
129
|
+
tmp_arr = []
|
129
130
|
@cell.each_pair {|key,value|
|
131
|
+
|
130
132
|
y,x = key.split(',')
|
131
133
|
x = x.to_i
|
132
134
|
y = y.to_i
|
133
135
|
if y == rownumber
|
134
|
-
|
136
|
+
tmp_arr[x] = value
|
135
137
|
end
|
136
138
|
}
|
139
|
+
result = tmp_arr[1..-1]
|
140
|
+
while result[-1] == nil
|
141
|
+
result = result[0..-2]
|
142
|
+
end
|
137
143
|
result
|
138
144
|
end
|
139
145
|
|
data/lib/roo/version.rb
CHANGED
data/test/numbers1.ods
CHANGED
Binary file
|
data/test/numbers1.xls
CHANGED
Binary file
|
data/test/test_roo.rb
CHANGED
@@ -2,11 +2,11 @@ require File.dirname(__FILE__) + '/test_helper.rb'
|
|
2
2
|
|
3
3
|
class TestRoo < Test::Unit::TestCase
|
4
4
|
|
5
|
-
OPENOFFICE = true
|
6
|
-
EXCEL
|
7
|
-
GOOGLE
|
5
|
+
OPENOFFICE = true # do Openoffice-Spreadsheet Tests?
|
6
|
+
EXCEL = true # do Excel Tests?
|
7
|
+
GOOGLE = false # do Google-Spreadsheet Tests?
|
8
8
|
|
9
|
-
OPENOFFICEWRITE = false #
|
9
|
+
OPENOFFICEWRITE = false # experimental: write access with OO-Dokuments
|
10
10
|
|
11
11
|
def setup
|
12
12
|
if GOOGLE
|
@@ -244,18 +244,32 @@ end
|
|
244
244
|
assert_equal 44, oo.cell('d',12)
|
245
245
|
assert_equal 45, oo.cell('e',12)
|
246
246
|
assert_equal [41.0,42.0,43.0,44.0,45.0], oo.row(12)
|
247
|
+
assert_equal "einundvierzig", oo.cell('a',16)
|
248
|
+
assert_equal "zweiundvierzig", oo.cell('b',16)
|
249
|
+
assert_equal "dreiundvierzig", oo.cell('c',16)
|
250
|
+
assert_equal "vierundvierzig", oo.cell('d',16)
|
251
|
+
assert_equal "fuenfundvierzig", oo.cell('e',16)
|
252
|
+
assert_equal ["einundvierzig", "zweiundvierzig", "dreiundvierzig", "vierundvierzig", "fuenfundvierzig"], oo.row(16)
|
247
253
|
if EXCEL
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
254
|
+
#-- Excel
|
255
|
+
oo = Excel.new(File.join("test","numbers1.xls"))
|
256
|
+
oo.default_sheet = 1 # oo.sheets.first
|
257
|
+
assert_equal 41, oo.cell('a',12)
|
258
|
+
assert_equal 42, oo.cell('b',12)
|
259
|
+
assert_equal 43, oo.cell('c',12)
|
260
|
+
assert_equal 44, oo.cell('d',12)
|
261
|
+
assert_equal 45, oo.cell('e',12)
|
262
|
+
assert_equal [41,42,43,44,45], oo.row(12)
|
263
|
+
assert_equal "einundvierzig", oo.cell('a',16)
|
264
|
+
assert_equal "zweiundvierzig", oo.cell('b',16)
|
265
|
+
assert_equal "dreiundvierzig", oo.cell('c',16)
|
266
|
+
assert_equal "vierundvierzig", oo.cell('d',16)
|
267
|
+
assert_equal "fuenfundvierzig", oo.cell('e',16)
|
268
|
+
assert_equal ["einundvierzig",
|
269
|
+
"zweiundvierzig",
|
270
|
+
"dreiundvierzig",
|
271
|
+
"vierundvierzig",
|
272
|
+
"fuenfundvierzig"], oo.row(16)
|
259
273
|
end
|
260
274
|
if DateTime.now > Date.new(2007,6,17)
|
261
275
|
#-- GOOGLE
|
@@ -268,6 +282,17 @@ end
|
|
268
282
|
assert_equal 44, oo.cell('d',12)
|
269
283
|
assert_equal 45, oo.cell('e',12)
|
270
284
|
assert_equal [41.0,42.0,43.0,44.0,45.0], oo.row(12)
|
285
|
+
assert_equal "einundvierzig", oo.cell('a',16)
|
286
|
+
assert_equal "zweiundvierzig", oo.cell('b',16)
|
287
|
+
assert_equal "dreiundvierzig", oo.cell('c',16)
|
288
|
+
assert_equal "vierundvierzig", oo.cell('d',16)
|
289
|
+
assert_equal "fuenfundvierzig", oo.cell('e',16)
|
290
|
+
assert_equal "xxxfuenfundvierzig", oo.cell('e',16)
|
291
|
+
assert_equal ["einundvierzig",
|
292
|
+
"zweiundvierzig",
|
293
|
+
"dreiundvierzig",
|
294
|
+
"vierundvierzig",
|
295
|
+
"fuenfundvierzig"], oo.row(16)
|
271
296
|
end
|
272
297
|
end
|
273
298
|
end
|
@@ -524,15 +549,51 @@ end
|
|
524
549
|
|
525
550
|
def test_bug_contiguous_cells
|
526
551
|
if OPENOFFICE
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
552
|
+
oo = Openoffice.new(File.join("test","numbers1.ods"))
|
553
|
+
oo.default_sheet = "Sheet4"
|
554
|
+
assert_equal Date.new(2007,06,16), oo.cell('a',1)
|
555
|
+
assert_equal 10, oo.cell('b',1)
|
556
|
+
assert_equal 10, oo.cell('c',1)
|
557
|
+
assert_equal 10, oo.cell('d',1)
|
558
|
+
assert_equal 10, oo.cell('e',1)
|
559
|
+
end
|
560
|
+
if EXCEL
|
561
|
+
oo = Excel.new(File.join("test","numbers1.xls"))
|
562
|
+
oo.default_sheet = 4
|
563
|
+
assert_equal Date.new(2007,06,16), oo.cell('a',1)
|
564
|
+
assert_equal 10, oo.cell('b',1)
|
565
|
+
assert_equal 10, oo.cell('c',1)
|
566
|
+
assert_equal 10, oo.cell('d',1)
|
567
|
+
assert_equal 10, oo.cell('e',1)
|
568
|
+
end
|
569
|
+
if GOOGLE
|
570
|
+
@goo.default_sheet = "Sheet4"
|
571
|
+
assert_equal Date.new(2007,06,16), @goo.cell('a',1)
|
572
|
+
assert_equal 10, @goo.cell('b',1)
|
573
|
+
assert_equal 10, @goo.cell('c',1)
|
574
|
+
assert_equal 10, @goo.cell('d',1)
|
575
|
+
assert_equal 10, @goo.cell('e',1)
|
534
576
|
end
|
577
|
+
end
|
535
578
|
|
579
|
+
def DONT_test_large_file
|
580
|
+
if OPENOFFICE
|
581
|
+
count = 0
|
582
|
+
oo = Openoffice.new(File.join("test","Bibelbund.ods"))
|
583
|
+
oo.default_sheet = oo.sheets.first
|
584
|
+
oo.first_row.upto(oo.last_row) do |row|
|
585
|
+
oo.first_column.upto(oo.last_column) do |col|
|
586
|
+
unless oo.empty?(row,col)
|
587
|
+
count += 1
|
588
|
+
a = oo.cell(row,col)
|
589
|
+
# puts a
|
590
|
+
# b = gets
|
591
|
+
end
|
592
|
+
end
|
593
|
+
end
|
594
|
+
puts count.to_s+" cells with content"
|
536
595
|
end
|
537
596
|
|
538
|
-
end
|
597
|
+
end
|
598
|
+
|
599
|
+
end # class
|
data/website/index.html
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
<h1>roo</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/roo"; return false'>
|
35
35
|
Get Version
|
36
|
-
<a href="http://rubyforge.org/projects/roo" class="numbers">0.2.
|
36
|
+
<a href="http://rubyforge.org/projects/roo" class="numbers">0.2.5</a>
|
37
37
|
</div>
|
38
38
|
<h2>What</h2>
|
39
39
|
|
metadata
CHANGED