roo 0.5.4 → 0.6.0
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 +5 -2
- data/Manifest.txt +1 -0
- data/lib/roo/google.rb +1 -1
- data/lib/roo/openoffice.rb +114 -49
- data/lib/roo/version.rb +2 -2
- data/test/numbers1.ods +0 -0
- data/test/ric.ods +0 -0
- data/test/test_roo.rb +178 -103
- data/website/index.html +24 -10
- data/website/index.txt +19 -3
- metadata +3 -2
data/History.txt
CHANGED
@@ -1,10 +1,13 @@
|
|
1
|
+
== 0.6.0 2007-10-06
|
2
|
+
* 1 enhancement:
|
3
|
+
* csv-output to stdout or file
|
1
4
|
== 0.5.4 2007-08-27
|
2
5
|
* 1 bugfix
|
3
6
|
* Openoffice: fixed a bug with internal representation of a spreadsheet (thanks to Ric Kamicar for the patch)
|
4
7
|
== 0.5.3 2007-08-26
|
5
8
|
* 2 enhancements:
|
6
|
-
*
|
7
|
-
*
|
9
|
+
* Openoffice: can now read zip-ed files
|
10
|
+
* Openoffice: can now read files from http://-URL over the net
|
8
11
|
== 0.5.2 2007-08-26
|
9
12
|
* 1 bugfix
|
10
13
|
* excel: removed debugging output
|
data/Manifest.txt
CHANGED
data/lib/roo/google.rb
CHANGED
data/lib/roo/openoffice.rb
CHANGED
@@ -6,6 +6,7 @@ require 'zip/zipfilesystem'
|
|
6
6
|
require 'date'
|
7
7
|
#require 'llip'
|
8
8
|
require 'base64'
|
9
|
+
require 'logger'
|
9
10
|
|
10
11
|
#require 'lib/roo/spreadsheetparser'
|
11
12
|
|
@@ -66,26 +67,6 @@ class Openoffice
|
|
66
67
|
f.close
|
67
68
|
end
|
68
69
|
|
69
|
-
#if false
|
70
|
-
#def reload
|
71
|
-
# @cells_read = false
|
72
|
-
# @tmpdir = "oo_"+$$.to_s
|
73
|
-
# unless File.exists?(@tmpdir)
|
74
|
-
# FileUtils::mkdir(@tmpdir)
|
75
|
-
# end
|
76
|
-
# extract_content
|
77
|
-
# file = File.new(File.join(@tmpdir, @file_nr.to_s+"_roo_content.xml"))
|
78
|
-
# @doc = REXML::Document.new file
|
79
|
-
# file.close
|
80
|
-
# @cell = Hash.new
|
81
|
-
# @cell_type = Hash.new
|
82
|
-
# FileUtils::rm_r(@tmpdir)
|
83
|
-
# @default_sheet = nil
|
84
|
-
# @first_column = @last_column = nil
|
85
|
-
# @first_row = @last_row = nil
|
86
|
-
#end
|
87
|
-
#end
|
88
|
-
|
89
70
|
# reopens and read a spreadsheet document
|
90
71
|
def reload
|
91
72
|
default_sheet = @default_sheet
|
@@ -155,6 +136,8 @@ class Openoffice
|
|
155
136
|
end
|
156
137
|
end
|
157
138
|
|
139
|
+
# recursively removes the current temporary directory
|
140
|
+
# this is only needed if you work with zipped files or files via the web
|
158
141
|
def remove_tmp
|
159
142
|
if File.exists?(@tmpdir)
|
160
143
|
FileUtils::rm_r(@tmpdir)
|
@@ -385,6 +368,18 @@ class Openoffice
|
|
385
368
|
result
|
386
369
|
end
|
387
370
|
|
371
|
+
# write the current spreadsheet to stdout or into a file
|
372
|
+
def to_csv(filename=nil)
|
373
|
+
if filename
|
374
|
+
file = File.open(filename,"w") # do |file|
|
375
|
+
write_csv_content(file)
|
376
|
+
file.close
|
377
|
+
else
|
378
|
+
write_csv_content
|
379
|
+
end
|
380
|
+
true
|
381
|
+
end
|
382
|
+
|
388
383
|
protected
|
389
384
|
|
390
385
|
def process_zipfile_packed(zip, path='')
|
@@ -410,7 +405,8 @@ protected
|
|
410
405
|
ret
|
411
406
|
end
|
412
407
|
|
413
|
-
|
408
|
+
private
|
409
|
+
def unzip(filename)
|
414
410
|
ret = nil
|
415
411
|
Zip::ZipFile.open(filename) do |zip|
|
416
412
|
ret = process_zipfile_packed zip
|
@@ -418,7 +414,6 @@ protected
|
|
418
414
|
ret
|
419
415
|
end
|
420
416
|
|
421
|
-
private
|
422
417
|
# read the version of the OO-Version
|
423
418
|
def oo_version
|
424
419
|
sheet_found = false
|
@@ -427,7 +422,27 @@ private
|
|
427
422
|
end
|
428
423
|
end
|
429
424
|
|
425
|
+
def belegen(x,y,i,v,vt,formula,tr,str_v)
|
426
|
+
@cell_type["#{y},#{x+i}"] = Openoffice.oo_type_2_roo_type(vt)
|
427
|
+
@formula["#{y},#{x+i}"] = formula if formula
|
428
|
+
if @cell_type["#{y},#{x+i}"] == :float
|
429
|
+
@cell["#{y},#{x+i}"] = v.to_f
|
430
|
+
elsif @cell_type["#{y},#{x+i}"] == :string
|
431
|
+
@cell["#{y},#{x+i}"] = str_v
|
432
|
+
elsif @cell_type["#{y},#{x}"] == :date
|
433
|
+
@cell["#{y},#{x}"] = tr.attributes['date-value']
|
434
|
+
elsif @cell_type["#{y},#{x+i}"] == :percentage
|
435
|
+
@cell["#{y},#{x+i}"] = v
|
436
|
+
else
|
437
|
+
@cell["#{y},#{x}"] = v
|
438
|
+
end
|
439
|
+
end
|
440
|
+
|
430
441
|
# read all cells in the selected sheet
|
442
|
+
#--
|
443
|
+
# the following construct means '4 blanks'
|
444
|
+
# some content <text:s text:c="3"/>
|
445
|
+
#++
|
431
446
|
def read_cells
|
432
447
|
sheet_found = false
|
433
448
|
raise ArgumentError, "Error: default_sheet not set" if @default_sheet == nil
|
@@ -462,45 +477,36 @@ private
|
|
462
477
|
vt = tr.attributes['value-type']
|
463
478
|
v = tr.attributes['value']
|
464
479
|
if vt == 'string'
|
480
|
+
str_v = ''
|
481
|
+
# insert \n if there is more than one paragraph
|
482
|
+
para_count = 0
|
465
483
|
tr.each_element do |str|
|
466
484
|
if str.name == 'p'
|
467
485
|
v = str.text
|
468
|
-
|
486
|
+
str_v += "\n" if para_count > 0
|
487
|
+
para_count += 1
|
488
|
+
if str.children.size > 1
|
489
|
+
str_v = children_to_string(str.children)
|
490
|
+
else
|
491
|
+
str.children.each {|child|
|
492
|
+
str_v = str_v + child.to_s #.text
|
493
|
+
}
|
494
|
+
end
|
495
|
+
str_v.gsub!(/"/,'"')
|
496
|
+
str_v.gsub!(/&/,'&')
|
497
|
+
str_v.gsub!(/'/,"'")
|
498
|
+
end # == 'p'
|
469
499
|
end
|
470
500
|
end
|
471
501
|
if skip
|
472
502
|
if v != nil
|
473
503
|
0.upto(skip.to_i-1) do |i|
|
474
|
-
|
475
|
-
@formula["#{y},#{x+i}"] = formula if formula
|
476
|
-
if @cell_type["#{y},#{x+i}"] == :float
|
477
|
-
@cell["#{y},#{x+i}"] = v.to_f
|
478
|
-
elsif @cell_type["#{y},#{x+i}"] == :string
|
479
|
-
@cell["#{y},#{x+i}"] = v
|
480
|
-
elsif @cell_type["#{y},#{x+i}"] == :date
|
481
|
-
@cell["#{y},#{x+i}"] = tr.attributes['date-value']
|
482
|
-
else
|
483
|
-
@cell["#{y},#{x+i}"] = v
|
484
|
-
end
|
504
|
+
belegen(x,y,i,v,vt,formula,tr,str_v)
|
485
505
|
end
|
486
506
|
end
|
487
507
|
x += (skip.to_i - 1)
|
488
508
|
end # if skip
|
489
|
-
|
490
|
-
@cell_type["#{y},#{x}"] = Openoffice.oo_type_2_roo_type(vt)
|
491
|
-
if @cell_type["#{y},#{x}"] == :float
|
492
|
-
@cell["#{y},#{x}"] = v.to_f
|
493
|
-
elsif @cell_type["#{y},#{x}"] == :string
|
494
|
-
tr.each_element do |str|
|
495
|
-
if str.name == 'p'
|
496
|
-
@cell["#{y},#{x}"] = str.text
|
497
|
-
end
|
498
|
-
end
|
499
|
-
elsif @cell_type["#{y},#{x}"] == :date
|
500
|
-
@cell["#{y},#{x}"] = tr.attributes['date-value']
|
501
|
-
else
|
502
|
-
@cell["#{y},#{x}"] = v
|
503
|
-
end
|
509
|
+
belegen(x,y,0,v,vt,formula,tr,str_v)
|
504
510
|
x += 1
|
505
511
|
end
|
506
512
|
end
|
@@ -650,4 +656,63 @@ private
|
|
650
656
|
f.close
|
651
657
|
File.join(@tmpdir, File.basename(uri))
|
652
658
|
end
|
659
|
+
|
660
|
+
def write_csv_content(file=nil)
|
661
|
+
file = STDOUT unless file
|
662
|
+
first_row.upto(last_row) do |row|
|
663
|
+
cells = []
|
664
|
+
1.upto(last_column) do |col|
|
665
|
+
file.print(",") if col > 1
|
666
|
+
onecell = cell(row,col)
|
667
|
+
onecelltype = celltype(row,col)
|
668
|
+
if empty?(row,col)
|
669
|
+
file.print('')
|
670
|
+
else
|
671
|
+
case onecelltype
|
672
|
+
when :string
|
673
|
+
if onecell == ""
|
674
|
+
file.print('')
|
675
|
+
else
|
676
|
+
onecell.gsub!(/"/,'""')
|
677
|
+
file.print('"'+onecell+'"')
|
678
|
+
end
|
679
|
+
when :float
|
680
|
+
if onecell == onecell.to_i
|
681
|
+
file.print onecell.to_i
|
682
|
+
else
|
683
|
+
file.print onecell
|
684
|
+
end
|
685
|
+
else
|
686
|
+
raise "unhandled celltype "+celltype.to_s
|
687
|
+
end
|
688
|
+
end
|
689
|
+
cells << onecell
|
690
|
+
end
|
691
|
+
file.print("\n")
|
692
|
+
end
|
693
|
+
end
|
694
|
+
|
695
|
+
# helper method to convert compressed spaces and other elements within
|
696
|
+
# an text into a string
|
697
|
+
def children_to_string(children)
|
698
|
+
result = ''
|
699
|
+
children.each {|child|
|
700
|
+
if child.class == REXML::Text
|
701
|
+
result = result + child.to_s
|
702
|
+
else
|
703
|
+
if child.name == 's'
|
704
|
+
compressed_spaces = child.attributes['c'].to_i
|
705
|
+
# no explicit number means a count of 1:
|
706
|
+
if compressed_spaces == 0
|
707
|
+
compressed_spaces = 1
|
708
|
+
end
|
709
|
+
result = result + " "*compressed_spaces
|
710
|
+
else
|
711
|
+
result = result + child.to_s
|
712
|
+
end
|
713
|
+
end
|
714
|
+
}
|
715
|
+
result
|
716
|
+
end
|
717
|
+
|
653
718
|
end # class
|
data/lib/roo/version.rb
CHANGED
data/test/numbers1.ods
CHANGED
Binary file
|
data/test/ric.ods
ADDED
Binary file
|
data/test/test_roo.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
2
|
#require 'soap/rpc/driver'
|
3
3
|
require 'fileutils'
|
4
|
+
require 'timeout'
|
4
5
|
include FileUtils
|
5
6
|
|
6
7
|
class TestRoo < Test::Unit::TestCase
|
@@ -10,6 +11,7 @@ class TestRoo < Test::Unit::TestCase
|
|
10
11
|
GOOGLE = false # do Google-Spreadsheet Tests?
|
11
12
|
|
12
13
|
OPENOFFICEWRITE = false # experimental: write access with OO-Documents
|
14
|
+
ONLINE = false
|
13
15
|
|
14
16
|
# helper method
|
15
17
|
def local_only
|
@@ -600,7 +602,7 @@ class TestRoo < Test::Unit::TestCase
|
|
600
602
|
|
601
603
|
oo1 = Openoffice.new(File.join("test","numbers2.ods"))
|
602
604
|
oo2 = Openoffice.new(File.join("test","bak_numbers2.ods"))
|
603
|
-
p oo2.to_s
|
605
|
+
#p oo2.to_s
|
604
606
|
assert_equal 999, oo2.cell('a',1), oo2.cell('a',1)
|
605
607
|
assert_equal oo2.cell('a',1) + 7, oo1.cell('a',1)
|
606
608
|
assert_equal oo2.cell('b',1)+7, oo1.cell('b',1)
|
@@ -711,58 +713,60 @@ class TestRoo < Test::Unit::TestCase
|
|
711
713
|
oo = Openoffice.new(File.join("test","simple_spreadsheet_from_italo.ods"))
|
712
714
|
oo.default_sheet = oo.sheets.first
|
713
715
|
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
716
|
+
after Date.new(2007,10,1) do
|
717
|
+
assert_equal '1', oo.cell('A',1)
|
718
|
+
assert_equal '1', oo.cell('B',1)
|
719
|
+
assert_equal '1', oo.cell('C',1)
|
720
|
+
|
721
|
+
# assert_equal 1, oo.cell('A',2)
|
722
|
+
# assert_equal 2, oo.cell('B',2)
|
723
|
+
# assert_equal 1, oo.cell('C',2)
|
724
|
+
# are stored as strings, not numbers
|
725
|
+
|
726
|
+
assert_equal 1, oo.cell('A',2).to_i
|
727
|
+
assert_equal 2, oo.cell('B',2).to_i
|
728
|
+
assert_equal 1, oo.cell('C',2).to_i
|
729
|
+
|
730
|
+
assert_equal 1, oo.cell('A',3)
|
731
|
+
assert_equal 3, oo.cell('B',3)
|
732
|
+
assert_equal 1, oo.cell('C',3)
|
733
|
+
|
734
|
+
assert_equal 'A', oo.cell('A',4)
|
735
|
+
assert_equal 'A', oo.cell('B',4)
|
736
|
+
assert_equal 'A', oo.cell('C',4)
|
737
|
+
|
738
|
+
assert_equal '0.01', oo.cell('A',5)
|
739
|
+
assert_equal '0.01', oo.cell('B',5)
|
740
|
+
assert_equal '0.01', oo.cell('C',5)
|
741
|
+
|
742
|
+
|
743
|
+
# 1.0
|
744
|
+
|
745
|
+
# Cells values in row 1:
|
746
|
+
assert_equal "1:string", oo.cell(1, 1)+":"+oo.celltype(1, 1).to_s
|
747
|
+
assert_equal "1:string",oo.cell(1, 2)+":"+oo.celltype(1, 2).to_s
|
748
|
+
assert_equal "1:string",oo.cell(1, 3)+":"+oo.celltype(1, 3).to_s
|
749
|
+
end
|
750
|
+
|
751
|
+
# Cells values in row 2:
|
752
|
+
assert_equal "1:string",oo.cell(2, 1)+":"+oo.celltype(2, 1).to_s
|
753
|
+
assert_equal "2:string",oo.cell(2, 2)+":"+oo.celltype(2, 2).to_s
|
754
|
+
assert_equal "1:string",oo.cell(2, 3)+":"+oo.celltype(2, 3).to_s
|
755
|
+
|
756
|
+
# Cells values in row 3:
|
757
|
+
assert_equal "1.0:float",oo.cell(3, 1).to_s+":"+oo.celltype(3, 1).to_s
|
758
|
+
assert_equal "3.0:float",oo.cell(3, 2).to_s+":"+oo.celltype(3, 2).to_s
|
759
|
+
assert_equal "1.0:float",oo.cell(3, 3).to_s+":"+oo.celltype(3, 3).to_s
|
760
|
+
|
761
|
+
# Cells values in row 4:
|
762
|
+
assert_equal "A:string",oo.cell(4, 1)+":"+oo.celltype(4, 1).to_s
|
763
|
+
assert_equal "A:string",oo.cell(4, 2)+":"+oo.celltype(4, 2).to_s
|
764
|
+
assert_equal "A:string",oo.cell(4, 3)+":"+oo.celltype(4, 3).to_s
|
765
|
+
|
766
|
+
# Cells values in row 5:
|
767
|
+
assert_equal "0.01:percentage",oo.cell(5, 1)+":"+oo.celltype(5, 1).to_s
|
768
|
+
assert_equal "0.01:percentage",oo.cell(5, 2)+":"+oo.celltype(5, 2).to_s
|
769
|
+
assert_equal "0.01:percentage",oo.cell(5, 3)+":"+oo.celltype(5, 3).to_s
|
766
770
|
end
|
767
771
|
|
768
772
|
end
|
@@ -831,8 +835,8 @@ class TestRoo < Test::Unit::TestCase
|
|
831
835
|
end
|
832
836
|
if EXCEL
|
833
837
|
oo = Excel.new(File.join("test","borders.xls"))
|
834
|
-
p oo.sheets
|
835
|
-
p oo.sheets[1]
|
838
|
+
#p oo.sheets
|
839
|
+
#p oo.sheets[1]
|
836
840
|
oo.default_sheet = oo.sheets[1]
|
837
841
|
assert_equal 6, oo.first_row
|
838
842
|
assert_equal 11, oo.last_row
|
@@ -1058,7 +1062,7 @@ class TestRoo < Test::Unit::TestCase
|
|
1058
1062
|
end
|
1059
1063
|
|
1060
1064
|
def test_excel_open_from_uri_and_zipped
|
1061
|
-
|
1065
|
+
if ONLINE
|
1062
1066
|
url = 'http://stiny-leonhard.de/bode-v1.xls.zip'
|
1063
1067
|
excel = Excel.new(url, :zip)
|
1064
1068
|
assert_equal 'ist "e" im Nenner von H(s)', excel.cell('b', 5)
|
@@ -1067,7 +1071,7 @@ class TestRoo < Test::Unit::TestCase
|
|
1067
1071
|
end
|
1068
1072
|
|
1069
1073
|
def test_openoffice_open_from_uri_and_zipped
|
1070
|
-
|
1074
|
+
if ONLINE
|
1071
1075
|
url = 'http://spazioinwind.libero.it/s2/rata.ods.zip'
|
1072
1076
|
sheet = Openoffice.new(url, :zip)
|
1073
1077
|
assert_equal 'ist "e" im Nenner von H(s)', sheet.cell('b', 5)
|
@@ -1076,48 +1080,50 @@ class TestRoo < Test::Unit::TestCase
|
|
1076
1080
|
end
|
1077
1081
|
|
1078
1082
|
def test_excel_zipped
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
excel.remove_tmp # don't forget to remove the temporary files
|
1084
|
-
end
|
1083
|
+
excel = Excel.new(File.join("test","bode-v1.xls.zip"), :zip)
|
1084
|
+
assert excel
|
1085
|
+
assert_equal 'ist "e" im Nenner von H(s)', excel.cell('b', 5)
|
1086
|
+
excel.remove_tmp # don't forget to remove the temporary files
|
1085
1087
|
end
|
1086
1088
|
|
1087
1089
|
def test_openoffice_zipped
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
oo.remove_tmp # don't forget to remove the temporary files
|
1094
|
-
end
|
1090
|
+
oo = Openoffice.new(File.join("test","bode-v1.ods.zip"), :zip)
|
1091
|
+
assert oo
|
1092
|
+
oo.default_sheet = oo.sheets.first
|
1093
|
+
assert_equal 'ist "e" im Nenner von H(s)', oo.cell('b', 5)
|
1094
|
+
oo.remove_tmp # don't forget to remove the temporary files
|
1095
1095
|
end
|
1096
1096
|
|
1097
1097
|
def test_bug_ric
|
1098
|
-
oo = Openoffice.new("
|
1098
|
+
oo = Openoffice.new(File.join("test","ric.ods"))
|
1099
1099
|
oo.default_sheet = oo.sheets.first
|
1100
1100
|
assert oo.empty?('A',1)
|
1101
1101
|
assert oo.empty?('B',1)
|
1102
1102
|
assert oo.empty?('C',1)
|
1103
1103
|
assert oo.empty?('D',1)
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
assert_equal
|
1112
|
-
assert_equal
|
1113
|
-
assert_equal
|
1114
|
-
assert_equal
|
1115
|
-
assert_equal
|
1116
|
-
assert_equal
|
1117
|
-
assert_equal
|
1118
|
-
assert_equal
|
1119
|
-
assert_equal
|
1120
|
-
assert_equal
|
1104
|
+
expected = 1
|
1105
|
+
letter = 'e'
|
1106
|
+
while letter <= 'u'
|
1107
|
+
assert_equal expected, oo.cell(letter,1)
|
1108
|
+
letter.succ!
|
1109
|
+
expected += 1
|
1110
|
+
end
|
1111
|
+
#assert_equal 2, oo.cell('f',1)
|
1112
|
+
#assert_equal 3, oo.cell('g',1)
|
1113
|
+
#assert_equal 4, oo.cell('h',1)
|
1114
|
+
#assert_equal 5, oo.cell('i',1)
|
1115
|
+
#assert_equal 6, oo.cell('j',1)
|
1116
|
+
#assert_equal 7, oo.cell('k',1)
|
1117
|
+
#assert_equal 8, oo.cell('l',1)
|
1118
|
+
#assert_equal 9, oo.cell('m',1)
|
1119
|
+
#assert_equal 10, oo.cell('n',1)
|
1120
|
+
#assert_equal 11, oo.cell('o',1)
|
1121
|
+
#assert_equal 12, oo.cell('p',1)
|
1122
|
+
#assert_equal 13, oo.cell('q',1)
|
1123
|
+
#assert_equal 14, oo.cell('r',1)
|
1124
|
+
#assert_equal 15, oo.cell('s',1)
|
1125
|
+
#assert_equal 16, oo.cell('t',1)
|
1126
|
+
#assert_equal 17, oo.cell('u',1)
|
1121
1127
|
assert_equal 'J', oo.cell('v',1)
|
1122
1128
|
assert_equal 'P', oo.cell('w',1)
|
1123
1129
|
assert_equal 'B', oo.cell('x',1)
|
@@ -1126,21 +1132,28 @@ class TestRoo < Test::Unit::TestCase
|
|
1126
1132
|
assert oo.empty?('b',2)
|
1127
1133
|
assert oo.empty?('c',2)
|
1128
1134
|
assert oo.empty?('d',2)
|
1129
|
-
|
1130
|
-
|
1131
|
-
assert_equal 'B', oo.cell(
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1135
|
+
|
1136
|
+
#'e'.upto('s') {|letter|
|
1137
|
+
# assert_equal 'B', oo.cell(letter,2)
|
1138
|
+
#}
|
1139
|
+
after Date.new(2007,10,1) do
|
1140
|
+
assert_equal 'B', oo.cell('e',2)
|
1141
|
+
assert_equal 'B', oo.cell('f',2)
|
1142
|
+
assert_equal 'B', oo.cell('g',2)
|
1143
|
+
assert_equal 'B', oo.cell('h',2)
|
1144
|
+
assert_equal 'B', oo.cell('i',2)
|
1145
|
+
assert_equal 'B', oo.cell('j',2)
|
1146
|
+
assert_equal 'B', oo.cell('k',2)
|
1147
|
+
assert_equal 'B', oo.cell('l',2)
|
1148
|
+
assert_equal 'B', oo.cell('m',2)
|
1149
|
+
assert_equal 'B', oo.cell('n',2)
|
1150
|
+
assert_equal 'B', oo.cell('o',2)
|
1151
|
+
assert_equal 'B', oo.cell('p',2)
|
1152
|
+
assert_equal 'B', oo.cell('q',2)
|
1153
|
+
assert_equal 'B', oo.cell('r',2)
|
1154
|
+
assert_equal 'B', oo.cell('s',2)
|
1155
|
+
end
|
1156
|
+
|
1144
1157
|
assert oo.empty?('t',2)
|
1145
1158
|
assert oo.empty?('u',2)
|
1146
1159
|
assert_equal 0 , oo.cell('v',2)
|
@@ -1148,4 +1161,66 @@ class TestRoo < Test::Unit::TestCase
|
|
1148
1161
|
assert_equal 15 , oo.cell('x',2)
|
1149
1162
|
assert_equal 15 , oo.cell('y',2)
|
1150
1163
|
end
|
1164
|
+
|
1165
|
+
def test_mehrteilig
|
1166
|
+
if OPENOFFICE
|
1167
|
+
oo = Openoffice.new(File.join("test","Bibelbund1.ods"))
|
1168
|
+
oo.default_sheet = oo.sheets.first
|
1169
|
+
assert_equal "Tagebuch des Sekret\303\244rs. Letzte Tagung 15./16.11.75 Schweiz", oo.cell(45,'A')
|
1170
|
+
end
|
1171
|
+
end
|
1172
|
+
|
1173
|
+
def test_to_csv
|
1174
|
+
after Date.new(2007,10,1) do
|
1175
|
+
if OPENOFFICE
|
1176
|
+
assert_nothing_raised(Timeout::Error) {
|
1177
|
+
Timeout::timeout(10*60*2) do |timeout_length|
|
1178
|
+
#puts Time.now.to_s + "test_to_csv Openoffice gestartet"
|
1179
|
+
oo = Openoffice.new(File.join("test","Bibelbund.ods"))
|
1180
|
+
oo.default_sheet = oo.sheets.first
|
1181
|
+
assert_equal "Tagebuch des Sekret\303\244rs. Letzte Tagung 15./16.11.75 Schweiz", oo.cell(45,'A')
|
1182
|
+
assert_equal "Tagebuch des Sekret\303\244rs. Nachrichten aus Chile", oo.cell(46,'A')
|
1183
|
+
assert_equal "Tagebuch aus Chile Juli 1977", oo.cell(55,'A')
|
1184
|
+
#puts Time.now.to_s + "vor to_csv"
|
1185
|
+
#assert oo.to_csv
|
1186
|
+
#puts Time.now.to_s + "nach to_csv"
|
1187
|
+
|
1188
|
+
#puts Time.now.to_s + "vor to_csv(datei)"
|
1189
|
+
assert oo.to_csv("/tmp/Bibelbund.csv")
|
1190
|
+
#puts Time.now.to_s + "nach to_csv(datei)"
|
1191
|
+
#puts Time.now.to_s + "vor File.exist"
|
1192
|
+
assert File.exists?("/tmp/Bibelbund.csv")
|
1193
|
+
#puts Time.now.to_s + "nach File.exist"
|
1194
|
+
assert_equal "", `diff test/Bibelbund.csv /tmp/Bibelbund.csv`
|
1195
|
+
#puts Time.now.to_s + "test_to_csv Openoffice beendet"
|
1196
|
+
end # Timeout
|
1197
|
+
} # nothing_raised
|
1198
|
+
end # OPENOFFICE
|
1199
|
+
end # after
|
1200
|
+
|
1201
|
+
after Date.new(2007,10,1) do
|
1202
|
+
if EXCEL
|
1203
|
+
assert_nothing_raised(Timeout::Error) {
|
1204
|
+
Timeout::timeout(10*60*2) do |timeout_length|
|
1205
|
+
#puts Time.now.to_s + "test_to_csv Excel gestartet"
|
1206
|
+
oo = Excel.new(File.join("test","Bibelbund.xls"))
|
1207
|
+
oo.default_sheet = oo.sheets.first
|
1208
|
+
#puts Time.now.to_s + "vor to_csv"
|
1209
|
+
#assert oo.to_csv
|
1210
|
+
#puts Time.now.to_s + "nach to_csv"
|
1211
|
+
#Timeout:timeout(3*60)) do |timeout_length|
|
1212
|
+
#puts Time.now.to_s + "vor to_csv(datei)"
|
1213
|
+
assert oo.to_csv("/tmp/Bibelbund.csv")
|
1214
|
+
#puts Time.now.to_s + "nach to_csv(datei)"
|
1215
|
+
#puts Time.now.to_s + "vor File.exist"
|
1216
|
+
assert File.exists?("/tmp/Bibelbund.csv")
|
1217
|
+
#puts Time.now.to_s + "nach File.exist"
|
1218
|
+
assert_equal "", `diff test/Bibelbund.csv /tmp/Bibelbund.csv`
|
1219
|
+
#puts Time.now.to_s + "test_to_csv Excel beendet"
|
1220
|
+
end
|
1221
|
+
}
|
1222
|
+
end
|
1223
|
+
end
|
1224
|
+
end # def to_csv
|
1225
|
+
|
1151
1226
|
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.
|
36
|
+
<a href="http://rubyforge.org/projects/roo" class="numbers">0.6.0</a>
|
37
37
|
</div>
|
38
38
|
<h2>What</h2>
|
39
39
|
|
@@ -213,6 +213,28 @@ oo.to_yaml({..}, 2,10, 300,10) # => only the rectangle from row 2, column 10
|
|
213
213
|
<p>This is not limited to a Rails application – you can also do further evaluations with your data.</p>
|
214
214
|
|
215
215
|
|
216
|
+
<h3><span class="caps">CSV</span>-Output</h3>
|
217
|
+
|
218
|
+
|
219
|
+
<p>You can generate output in csv-format with</p>
|
220
|
+
|
221
|
+
|
222
|
+
<pre>
|
223
|
+
<code>
|
224
|
+
oo.to_csv
|
225
|
+
</code>
|
226
|
+
</pre>
|
227
|
+
|
228
|
+
to write to the standard output or
|
229
|
+
<pre>
|
230
|
+
<code>
|
231
|
+
oo.to_csv("somefile.txt")
|
232
|
+
</code>
|
233
|
+
</pre>
|
234
|
+
|
235
|
+
<p>to write to a file.</p>
|
236
|
+
|
237
|
+
|
216
238
|
<h3>Using MS-Excel spreadsheets</h3>
|
217
239
|
|
218
240
|
|
@@ -230,9 +252,6 @@ Replace Openoffice with
|
|
230
252
|
is the setting of the default-worksheet. OpenOffice uses the name of the worksheet whereas Excel needs the index of the worksheet (1,2,3,..).</p>
|
231
253
|
|
232
254
|
|
233
|
-
<p><span class="caps">EDIT</span>: since the release 0.4.2, default_sheet in Excel-object can be handled with names like the Openoffice-sheet.</p>
|
234
|
-
|
235
|
-
|
236
255
|
<p>Formulas can only be handled in OpenOffice-spreadsheets.</p>
|
237
256
|
|
238
257
|
|
@@ -245,11 +264,6 @@ is the setting of the default-worksheet. OpenOffice uses the name of the workshe
|
|
245
264
|
<td>Open Office</td>
|
246
265
|
<td>Excel</td>
|
247
266
|
</tr>
|
248
|
-
<tr>
|
249
|
-
<td>default_sheet</td>
|
250
|
-
<td>as name</td>
|
251
|
-
<td>as number or name (>=0.4.2)</td>
|
252
|
-
</tr>
|
253
267
|
<tr>
|
254
268
|
<td>formulas</td>
|
255
269
|
<td>yes</td>
|
@@ -398,7 +412,7 @@ Remote access with <span class="caps">SOAP</span> is nothing specific to roo, yo
|
|
398
412
|
<li>Dirk Huth fürs Testen unter Windows</li>
|
399
413
|
</ul>
|
400
414
|
<p class="coda">
|
401
|
-
<a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>,
|
415
|
+
<a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>, 3rd October 2007<br>
|
402
416
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
403
417
|
</p>
|
404
418
|
</div>
|
data/website/index.txt
CHANGED
@@ -142,6 +142,25 @@ With the YAML output you can import your data in a Ruby on Rails application in
|
|
142
142
|
|
143
143
|
This is not limited to a Rails application - you can also do further evaluations with your data.
|
144
144
|
|
145
|
+
h3. CSV-Output
|
146
|
+
|
147
|
+
You can generate output in csv-format with
|
148
|
+
|
149
|
+
<pre>
|
150
|
+
<code>
|
151
|
+
oo.to_csv
|
152
|
+
</code>
|
153
|
+
</pre>
|
154
|
+
|
155
|
+
to write to the standard output or
|
156
|
+
<pre>
|
157
|
+
<code>
|
158
|
+
oo.to_csv("somefile.txt")
|
159
|
+
</code>
|
160
|
+
</pre>
|
161
|
+
|
162
|
+
to write to a file.
|
163
|
+
|
145
164
|
h3. Using MS-Excel spreadsheets
|
146
165
|
|
147
166
|
You can also access MS-Excel spreadsheat.
|
@@ -156,15 +175,12 @@ Replace Openoffice with
|
|
156
175
|
All methode are the same for OpenOffice and Excel-objects. The only difference
|
157
176
|
is the setting of the default-worksheet. OpenOffice uses the name of the worksheet whereas Excel needs the index of the worksheet (1,2,3,..).
|
158
177
|
|
159
|
-
EDIT: since the release 0.4.2, default_sheet in Excel-object can be handled with names like the Openoffice-sheet.
|
160
|
-
|
161
178
|
Formulas can only be handled in OpenOffice-spreadsheets.
|
162
179
|
|
163
180
|
Features in OpenOffice and Excel:
|
164
181
|
|
165
182
|
table(border:1px solid black).
|
166
183
|
|feature|Open Office|Excel|
|
167
|
-
|default_sheet|as name|as number or name (>=0.4.2)|
|
168
184
|
|formulas|yes|no|
|
169
185
|
|to_yaml|yes|yes|
|
170
186
|
|
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.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.6.0
|
7
|
+
date: 2007-10-06 00:00:00 +02:00
|
8
8
|
summary: roo can access the contents of OpenOffice-Spreadsheets and Excel-Spreadsheets
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -56,6 +56,7 @@ files:
|
|
56
56
|
- test/only_one_sheet.xls
|
57
57
|
- test/bode-v1.xls.zip
|
58
58
|
- test/bode-v1.ods.zip
|
59
|
+
- test/ric.ods
|
59
60
|
- website/index.html
|
60
61
|
- website/index.txt
|
61
62
|
- website/javascripts/rounded_corners_lite.inc.js
|