roo 0.2.5 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/lib/roo/excel.rb +2 -0
- data/lib/roo/openoffice.rb +15 -5
- data/lib/roo/version.rb +1 -1
- data/test/numbers1.ods +0 -0
- data/test/numbers1.xls +0 -0
- data/test/test_roo.rb +83 -1
- data/website/index.html +2 -2
- metadata +2 -2
data/History.txt
CHANGED
data/lib/roo/excel.rb
CHANGED
@@ -47,6 +47,7 @@ class Excel < Openoffice
|
|
47
47
|
cell = row_par.at(col-1)
|
48
48
|
# p "celltype: "
|
49
49
|
# p cell.type
|
50
|
+
return nil unless cell
|
50
51
|
case cell.type
|
51
52
|
when :numeric then return cell.to_i
|
52
53
|
when :text then return cell.to_s('latin1')
|
@@ -67,6 +68,7 @@ class Excel < Openoffice
|
|
67
68
|
worksheet.each(skip) { |row_par|
|
68
69
|
if line == row
|
69
70
|
cell = row_par.at(col-1)
|
71
|
+
return nil unless cell
|
70
72
|
case cell.type
|
71
73
|
when :numeric then return "float"
|
72
74
|
when :text then return "string"
|
data/lib/roo/openoffice.rb
CHANGED
@@ -287,6 +287,13 @@ private
|
|
287
287
|
skip = tr.attributes['number-columns-repeated']
|
288
288
|
vt = tr.attributes['value-type']
|
289
289
|
v = tr.attributes['value']
|
290
|
+
if vt == 'string'
|
291
|
+
tr.each_element do |str|
|
292
|
+
if str.name == 'p'
|
293
|
+
v = str.text
|
294
|
+
end
|
295
|
+
end
|
296
|
+
end
|
290
297
|
if skip
|
291
298
|
if v == nil
|
292
299
|
x += (skip.to_i - 1)
|
@@ -296,11 +303,14 @@ private
|
|
296
303
|
if @cell_type["#{y},#{x+i}"] == 'float'
|
297
304
|
@cell["#{y},#{x+i}"] = v.to_f
|
298
305
|
elsif @cell_type["#{y},#{x+i}"] == 'string'
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
end
|
306
|
+
# puts "in string zweig..."
|
307
|
+
#tr.each_element do |str|
|
308
|
+
# if str.name == 'p'
|
309
|
+
# @cell["#{y},#{x+i}"] = str.text
|
310
|
+
# end
|
311
|
+
#end
|
312
|
+
@cell["#{y},#{x+i}"] = v
|
313
|
+
|
304
314
|
elsif @cell_type["#{y},#{x+i}"] == 'date'
|
305
315
|
@cell["#{y},#{x+i}"] = tr.attributes['date-value']
|
306
316
|
else
|
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
@@ -29,7 +29,7 @@ class TestRoo < Test::Unit::TestCase
|
|
29
29
|
|
30
30
|
def test_sheets
|
31
31
|
oo = Openoffice.new(File.join("test","numbers1.ods"))
|
32
|
-
assert_equal ["Tabelle1","Name of Sheet 2","Sheet3","Sheet4"], oo.sheets
|
32
|
+
assert_equal ["Tabelle1","Name of Sheet 2","Sheet3","Sheet4","Sheet5"], oo.sheets
|
33
33
|
#--
|
34
34
|
if EXCEL
|
35
35
|
if DateTime.now > Date.new(2007,6,30)
|
@@ -576,6 +576,27 @@ end
|
|
576
576
|
end
|
577
577
|
end
|
578
578
|
|
579
|
+
def test_bug_italo_ve
|
580
|
+
if OPENOFFICE
|
581
|
+
oo = Openoffice.new(File.join("test","numbers1.ods"))
|
582
|
+
oo.default_sheet = "Sheet5"
|
583
|
+
assert_equal 1, oo.cell('A',1)
|
584
|
+
assert_equal 5, oo.cell('b',1)
|
585
|
+
assert_equal 5, oo.cell('c',1)
|
586
|
+
assert_equal 2, oo.cell('a',2)
|
587
|
+
assert_equal 3, oo.cell('a',3)
|
588
|
+
end
|
589
|
+
if EXCEL
|
590
|
+
oo = Excel.new(File.join("test","numbers1.xls"))
|
591
|
+
oo.default_sheet = 5
|
592
|
+
assert_equal 1, oo.cell('A',1)
|
593
|
+
assert_equal 5, oo.cell('b',1)
|
594
|
+
assert_equal 5, oo.cell('c',1)
|
595
|
+
assert_equal 2, oo.cell('a',2)
|
596
|
+
assert_equal 3, oo.cell('a',3)
|
597
|
+
end
|
598
|
+
end
|
599
|
+
|
579
600
|
def DONT_test_large_file
|
580
601
|
if OPENOFFICE
|
581
602
|
count = 0
|
@@ -595,5 +616,66 @@ end
|
|
595
616
|
end
|
596
617
|
|
597
618
|
end
|
619
|
+
|
620
|
+
def test_italo_table
|
621
|
+
oo = Openoffice.new(File.join("test","simple_spreadsheet_from_italo.ods"))
|
622
|
+
p oo.sheets
|
623
|
+
oo.default_sheet = oo.sheets.first
|
624
|
+
|
625
|
+
assert_equal '1', oo.cell('A',1)
|
626
|
+
assert_equal '1', oo.cell('B',1)
|
627
|
+
assert_equal '1', oo.cell('C',1)
|
628
|
+
|
629
|
+
# assert_equal 1, oo.cell('A',2)
|
630
|
+
# assert_equal 2, oo.cell('B',2)
|
631
|
+
# assert_equal 1, oo.cell('C',2)
|
632
|
+
# are stored as strings, not numbers
|
633
|
+
|
634
|
+
assert_equal 1, oo.cell('A',2).to_i
|
635
|
+
assert_equal 2, oo.cell('B',2).to_i
|
636
|
+
assert_equal 1, oo.cell('C',2).to_i
|
637
|
+
|
638
|
+
assert_equal 1, oo.cell('A',3)
|
639
|
+
assert_equal 3, oo.cell('B',3)
|
640
|
+
assert_equal 1, oo.cell('C',3)
|
641
|
+
|
642
|
+
assert_equal 'A', oo.cell('A',4)
|
643
|
+
assert_equal 'A', oo.cell('B',4)
|
644
|
+
assert_equal 'A', oo.cell('C',4)
|
645
|
+
|
646
|
+
assert_equal '0.01', oo.cell('A',5)
|
647
|
+
assert_equal '0.01', oo.cell('B',5)
|
648
|
+
assert_equal '0.01', oo.cell('C',5)
|
649
|
+
|
650
|
+
|
651
|
+
# 1.0
|
652
|
+
|
653
|
+
# Cells values in row 1:
|
654
|
+
assert_equal "1:string", oo.cell(1, 1)+":"+oo.celltype(1, 1)
|
655
|
+
assert_equal "1:string",oo.cell(1, 2)+":"+oo.celltype(1, 2)
|
656
|
+
assert_equal "1:string",oo.cell(1, 3)+":"+oo.celltype(1, 3)
|
657
|
+
|
658
|
+
# Cells values in row 2:
|
659
|
+
assert_equal "1:string",oo.cell(2, 1)+":"+oo.celltype(2, 1)
|
660
|
+
assert_equal "2:string",oo.cell(2, 2)+":"+oo.celltype(2, 2)
|
661
|
+
assert_equal "1:string",oo.cell(2, 3)+":"+oo.celltype(2, 3)
|
662
|
+
|
663
|
+
# Cells values in row 3:
|
664
|
+
assert_equal "1.0:float",oo.cell(3, 1).to_s+":"+oo.celltype(3, 1)
|
665
|
+
assert_equal "3.0:float",oo.cell(3, 2).to_s+":"+oo.celltype(3, 2)
|
666
|
+
assert_equal "1.0:float",oo.cell(3, 3).to_s+":"+oo.celltype(3, 3)
|
667
|
+
|
668
|
+
# Cells values in row 4:
|
669
|
+
assert_equal "A:string",oo.cell(4, 1)+":"+oo.celltype(4, 1)
|
670
|
+
assert_equal "A:string",oo.cell(4, 2)+":"+oo.celltype(4, 2)
|
671
|
+
assert_equal "A:string",oo.cell(4, 3)+":"+oo.celltype(4, 3)
|
672
|
+
|
673
|
+
# Cells values in row 5:
|
674
|
+
assert_equal "0.01:percentage",oo.cell(5, 1)+":"+oo.celltype(5, 1)
|
675
|
+
assert_equal "0.01:percentage",oo.cell(5, 2)+":"+oo.celltype(5, 2)
|
676
|
+
assert_equal "0.01:percentage",oo.cell(5, 3)+":"+oo.celltype(5, 3)
|
677
|
+
|
678
|
+
|
679
|
+
end
|
598
680
|
|
599
681
|
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.6</a>
|
37
37
|
</div>
|
38
38
|
<h2>What</h2>
|
39
39
|
|
@@ -199,7 +199,7 @@ is the setting of the default-worksheet. OpenOffice uses the name of the workshe
|
|
199
199
|
<li>Dirk Huth fürs Testen unter Windows</li>
|
200
200
|
</ul>
|
201
201
|
<p class="coda">
|
202
|
-
<a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>,
|
202
|
+
<a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>, 18th June 2007<br>
|
203
203
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
204
204
|
</p>
|
205
205
|
</div>
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: roo
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.2.
|
7
|
-
date: 2007-06-
|
6
|
+
version: 0.2.6
|
7
|
+
date: 2007-06-19 00:00:00 +02:00
|
8
8
|
summary: roo can access the contents of OpenOffice-Spreadsheets
|
9
9
|
require_paths:
|
10
10
|
- lib
|