test/test_roo.rb in roo-0.4.1 vs test/test_roo.rb in roo-0.5.0
- old
+ new
@@ -1,15 +1,39 @@
require File.dirname(__FILE__) + '/test_helper.rb'
+#require 'soap/rpc/driver'
+require 'fileutils'
+include FileUtils
class TestRoo < Test::Unit::TestCase
OPENOFFICE = true # do Openoffice-Spreadsheet Tests?
EXCEL = true # do Excel Tests?
GOOGLE = false # do Google-Spreadsheet Tests?
- OPENOFFICEWRITE = false # experimental: write access with OO-Dokuments
+ OPENOFFICEWRITE = false # experimental: write access with OO-Documents
+ # helper method
+ def local_only
+ if ENV["roo_local"] == "thomas-p"
+ yield
+ end
+ end
+
+ # helper method
+ def after(d)
+ if DateTime.now > d
+ yield
+ end
+ end
+
+ # helper method
+ def before(d)
+ if DateTime.now <= d
+ yield
+ end
+ end
+
def setup
if GOOGLE
@goo = Google.new(ENV['GOOGLE_MAIL'],
ENV['GOOGLE_PASSWORD'],
ENV['GOOGLE_KEY'])
@@ -26,29 +50,28 @@
assert_equal 27, Openoffice.letter_to_number('Aa')
assert_equal 27, Openoffice.letter_to_number('aa')
end
def test_sheets
- oo = Openoffice.new(File.join("test","numbers1.ods"))
- assert_equal ["Tabelle1","Name of Sheet 2","Sheet3","Sheet4","Sheet5"], oo.sheets
- #--
+ if OPENOFFICE
+ oo = Openoffice.new(File.join("test","numbers1.ods"))
+ assert_equal ["Tabelle1","Name of Sheet 2","Sheet3","Sheet4","Sheet5"], oo.sheets
+ end
if EXCEL
-if DateTime.now > Date.new(2007,6,30)
oo = Excel.new(File.join("test","numbers1.xls"))
- assert_equal ["Tabelle1","Name of Sheet 2","Sheet3"], oo.sheets
-end
+ assert_equal ["Tabelle1","Name of Sheet 2","Sheet3","Sheet4","Sheet5"], oo.sheets
end
- #-- Google
if GOOGLE
- if DateTime.now > Date.new(2007,6,10)
+ after Date.new(2007,6,10) do
assert_equal "Testspreadsheet Roo", @goo.title
end
assert_equal ["Sheet eins","Sheet zwei","Sheet drei"], @goo.sheets
end
end
def test_cell
+ if OPENOFFICE
oo = Openoffice.new(File.join("test","numbers1.ods"))
oo.default_sheet = oo.sheets.first
assert_equal 1, oo.cell(1,1)
assert_equal 2, oo.cell(1,2)
assert_equal 3, oo.cell(1,3)
@@ -57,13 +80,15 @@
assert_equal 6, oo.cell(2,2)
assert_equal 7, oo.cell(2,3)
assert_equal 8, oo.cell(2,4)
assert_equal 9, oo.cell(2,5)
assert_equal "test", oo.cell(2,6)
- assert_equal "string", oo.celltype(2,6)
+ # assert_equal "string", oo.celltype(2,6)
+ assert_equal :string, oo.celltype(2,6)
assert_equal 11, oo.cell(2,7)
- assert_equal "float", oo.celltype(2,7)
+ # assert_equal "float", oo.celltype(2,7)
+ assert_equal :float, oo.celltype(2,7)
assert_equal 10, oo.cell(4,1)
assert_equal 11, oo.cell(4,2)
assert_equal 12, oo.cell(4,3)
assert_equal 13, oo.cell(4,4)
@@ -73,30 +98,34 @@
assert_equal 11, oo.cell(4,'B')
assert_equal 12, oo.cell(4,'C')
assert_equal 13, oo.cell(4,'D')
assert_equal 14, oo.cell(4,'E')
- assert_equal "date", oo.celltype(5,1)
+ # assert_equal "date", oo.celltype(5,1)
+ assert_equal :date, oo.celltype(5,1)
assert_equal Date.new(1961,11,21), oo.cell(5,1)
assert_equal "1961-11-21", oo.cell(5,1).to_s
+ end
if EXCEL
oo = Excel.new(File.join("test","numbers1.xls"))
- oo.default_sheet = 1 # oo.sheets.first
+ oo.default_sheet = oo.sheets.first
assert_equal 1, oo.cell(1,1)
assert_equal 2, oo.cell(1,2)
assert_equal 3, oo.cell(1,3)
assert_equal 4, oo.cell(1,4)
assert_equal 5, oo.cell(2,1)
assert_equal 6, oo.cell(2,2)
assert_equal 7, oo.cell(2,3)
assert_equal 8, oo.cell(2,4)
assert_equal 9, oo.cell(2,5)
assert_equal "test", oo.cell(2,6)
- assert_equal "string", oo.celltype(2,6)
+ # assert_equal "string", oo.celltype(2,6)
+ assert_equal :string, oo.celltype(2,6)
assert_equal 11, oo.cell(2,7)
- assert_equal "float", oo.celltype(2,7)
+ # assert_equal "float", oo.celltype(2,7)
+ assert_equal :float, oo.celltype(2,7)
assert_equal 10, oo.cell(4,1)
assert_equal 11, oo.cell(4,2)
assert_equal 12, oo.cell(4,3)
assert_equal 13, oo.cell(4,4)
@@ -106,11 +135,12 @@
assert_equal 11, oo.cell(4,'B')
assert_equal 12, oo.cell(4,'C')
assert_equal 13, oo.cell(4,'D')
assert_equal 14, oo.cell(4,'E')
- assert_equal "date", oo.celltype(5,1)
+ # assert_equal "date", oo.celltype(5,1)
+ assert_equal :date, oo.celltype(5,1)
assert_equal Date.new(1961,11,21), oo.cell(5,1)
assert_equal "1961-11-21", oo.cell(5,1).to_s
end
if GOOGLE
@@ -123,14 +153,16 @@
assert_equal 6, @goo.cell(2,2).to_i
assert_equal 7, @goo.cell(2,3).to_i
assert_equal 8, @goo.cell(2,4).to_i
assert_equal 9, @goo.cell(2,5).to_i
assert_equal "test", @goo.cell(2,6)
- assert_equal "string", @goo.celltype(2,6)
+ # assert_equal "string", @goo.celltype(2,6)
+ assert_equal :string, @goo.celltype(2,6)
assert_equal 11, @goo.cell(2,7).to_i
- if DateTime.now > Date.new(2007,6,15)
- assert_equal "float", @goo.celltype(2,7)
+ after Date.new(2007,6,15) do
+ # assert_equal "float", @goo.celltype(2,7)
+ assert_equal :float, @goo.celltype(2,7)
end
assert_equal 10, @goo.cell(4,1).to_i
assert_equal 11, @goo.cell(4,2).to_i
assert_equal 12, @goo.cell(4,3).to_i
@@ -141,49 +173,66 @@
assert_equal 11, @goo.cell(4,'B').to_i
assert_equal 12, @goo.cell(4,'C').to_i
assert_equal 13, @goo.cell(4,'D').to_i
assert_equal 14, @goo.cell(4,'E').to_i
- if DateTime.now > Date.new(2007,6,15)
- assert_equal "date", @goo.celltype(5,1)
+ after Date.new(2007,6,15) do
+ # assert_equal "date", @goo.celltype(5,1)
+ assert_equal :date, @goo.celltype(5,1)
end
- if DateTime.now > Date.new(2007,6,15)
+ after Date.new(2007,6,15) do
assert_equal Date.new(1961,11,21), @goo.cell(5,1)
assert_equal "1961-11-21", @goo.cell(5,1).to_s
- else
+ end
+ before Date.new(2007,6,15) do
assert_equal "21/11/1961", @goo.cell(5,1)
end
end # GOOGLE
end
def test_cell_address
- oo = Openoffice.new(File.join("test/numbers1.ods"))
- oo.default_sheet = oo.sheets.first
- assert_equal "tata", oo.cell(6,1)
- assert_equal "tata", oo.cell(6,'A')
- assert_equal "tata", oo.cell('A',6)
- assert_equal "tata", oo.cell(6,'a')
- assert_equal "tata", oo.cell('a',6)
+ if OPENOFFICE
+ oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo.default_sheet = oo.sheets.first
+ assert_equal "tata", oo.cell(6,1)
+ assert_equal "tata", oo.cell(6,'A')
+ assert_equal "tata", oo.cell('A',6)
+ assert_equal "tata", oo.cell(6,'a')
+ assert_equal "tata", oo.cell('a',6)
+
+ assert_raise(ArgumentError) {
+ assert_equal "tata", oo.cell('a','f')
+ }
+ assert_raise(ArgumentError) {
+ assert_equal "tata", oo.cell('f','a')
+ }
+ assert_equal "thisisc8", oo.cell(8,3)
+ assert_equal "thisisc8", oo.cell(8,'C')
+ assert_equal "thisisc8", oo.cell('C',8)
+ assert_equal "thisisc8", oo.cell(8,'c')
+ assert_equal "thisisc8", oo.cell('c',8)
+
+ assert_equal "thisisd9", oo.cell('d',9)
+ assert_equal "thisisa11", oo.cell('a',11)
+ end
- assert_equal "thisisc8", oo.cell(8,3)
- assert_equal "thisisc8", oo.cell(8,'C')
- assert_equal "thisisc8", oo.cell('C',8)
- assert_equal "thisisc8", oo.cell(8,'c')
- assert_equal "thisisc8", oo.cell('c',8)
-
- assert_equal "thisisd9", oo.cell('d',9)
- assert_equal "thisisa11", oo.cell('a',11)
-
if EXCEL
oo = Excel.new(File.join("test","numbers1.xls"))
- oo.default_sheet = 1 # oo.sheets.first
+ oo.default_sheet = oo.sheets.first
assert_equal "tata", oo.cell(6,1)
assert_equal "tata", oo.cell(6,'A')
assert_equal "tata", oo.cell('A',6)
assert_equal "tata", oo.cell(6,'a')
assert_equal "tata", oo.cell('a',6)
+ assert_raise(ArgumentError) {
+ assert_equal "tata", oo.cell('a','f')
+ }
+ assert_raise(ArgumentError) {
+ assert_equal "tata", oo.cell('f','a')
+ }
+
assert_equal "thisisc8", oo.cell(8,3)
assert_equal "thisisc8", oo.cell(8,'C')
assert_equal "thisisc8", oo.cell('C',8)
assert_equal "thisisc8", oo.cell(8,'c')
assert_equal "thisisc8", oo.cell('c',8)
@@ -220,18 +269,18 @@
assert_equal "1.0", oo.officeversion
if EXCEL
# excel does not have a officeversion
# is there a similar version number which ist considerable
#-- Excel
- #if DateTime.now > Date.new(2007,6,15)
+ #after Date.new(2007,6,15) do
# oo = Excel.new(File.join("test","numbers1.xls"))
# assert_equal "1.0", oo.officeversion
#end
end
#-- Google
if GOOGLE
- if DateTime.now > Date.new(2007,6,15)
+ after Date.new(2007,6,15) do
assert_equal "1.0", @goo.officeversion
end
end
end
@@ -252,11 +301,11 @@
assert_equal "fuenfundvierzig", oo.cell('e',16)
assert_equal ["einundvierzig", "zweiundvierzig", "dreiundvierzig", "vierundvierzig", "fuenfundvierzig"], oo.row(16)
if EXCEL
#-- Excel
oo = Excel.new(File.join("test","numbers1.xls"))
- oo.default_sheet = 1 # oo.sheets.first
+ oo.default_sheet = oo.sheets.first
assert_equal 41, oo.cell('a',12)
assert_equal 42, oo.cell('b',12)
assert_equal 43, oo.cell('c',12)
assert_equal 44, oo.cell('d',12)
assert_equal 45, oo.cell('e',12)
@@ -270,11 +319,11 @@
"zweiundvierzig",
"dreiundvierzig",
"vierundvierzig",
"fuenfundvierzig"], oo.row(16)
end
- if DateTime.now > Date.new(2007,6,17)
+ after Date.new(2007,6,17) do
#-- GOOGLE
if GOOGLE
oo = Google.new(File.join("test","numbers1.xls"))
oo.default_sheet = 1 # oo.sheets.first
assert_equal 41, oo.cell('a',12)
@@ -297,37 +346,37 @@
end
end
end
def test_last_row
- #-- OpenOffice
- oo = Openoffice.new(File.join("test","numbers1.ods"))
- oo.default_sheet = oo.sheets.first
- assert_equal 18, oo.last_row
+ if OPENOFFICE
+ oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo.default_sheet = oo.sheets.first
+ assert_equal 18, oo.last_row
+ end
if EXCEL
- #-- Excel
oo = Excel.new(File.join("test","numbers1.xls"))
- oo.default_sheet = 1 # oo.sheets.first
+ oo.default_sheet = oo.sheets.first
assert_equal 18, oo.last_row
end
if GOOGLE
- #-- Google
@goo.default_sheet = @goo.sheets.first
assert_equal 18, @goo.last_row
assert_equal "xxx", @goo.to_s, @goo.to_s
end
end
def test_last_column
- #-- OpenOffice
- oo = Openoffice.new(File.join("test","numbers1.ods"))
- oo.default_sheet = oo.sheets.first
- assert_equal 7, oo.last_column
+ if OPENOFFICE
+ oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo.default_sheet = oo.sheets.first
+ assert_equal 7, oo.last_column
+ end
if EXCEL
#-- Excel
oo = Excel.new(File.join("test","numbers1.xls"))
- oo.default_sheet = 1 # oo.sheets.first
+ oo.default_sheet = oo.sheets.first
assert_equal 7, oo.last_column
end
if GOOGLE
#-- Google
@goo.default_sheet = @goo.sheets.first
@@ -406,21 +455,20 @@
assert_equal 'A', @goo.first_column_as_letter
end
end
def test_sheetname
- #-- OpenOffice
- oo = Openoffice.new(File.join("test","numbers1.ods"))
- oo.default_sheet = "Name of Sheet 2"
- assert_equal 'I am sheet 2', oo.cell('C',5)
- if DateTime.now > Date.new(2007,6,16)
- #-- Excel
- if DateTime.now > Date.new(2007,6,30)
+ if OPENOFFICE
+ #-- OpenOffice
+ oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo.default_sheet = "Name of Sheet 2"
+ assert_equal 'I am sheet 2', oo.cell('C',5)
+ end
+ if EXCEL
oo = Excel.new(File.join("test","numbers1.xls"))
oo.default_sheet = "Name of Sheet 2"
assert_equal 'I am sheet 2', oo.cell('C',5)
- end
end
end
def test_boundaries
#-- OpenOffice
@@ -469,13 +517,15 @@
end
def test_argument_error
if EXCEL
oo = Excel.new(File.join("test","numbers1.xls"))
- assert_raise(ArgumentError) {
- oo.default_sheet = "first sheet"
- }
+ before Date.new(2007,7,20) do
+ assert_raise(ArgumentError) {
+ oo.default_sheet = "first sheet"
+ }
+ end
assert_nothing_raised(ArgumentError) {
oo.default_sheet = 1
}
end
end
@@ -506,11 +556,12 @@
oo = Openoffice.new(File.join("test","numbers2.ods"))
oo.default_sheet = oo.sheets.first
oo.first_row.upto(oo.last_row) {|y|
oo.first_column.upto(oo.last_column) {|x|
unless oo.empty?(y,x)
- oo.set(y, x, oo.cell(y,x) + 7) if oo.celltype(y,x) == "float"
+ # oo.set(y, x, oo.cell(y,x) + 7) if oo.celltype(y,x) == "float"
+ oo.set(y, x, oo.cell(y,x) + 7) if oo.celltype(y,x) == :float
end
}
}
oo.save
@@ -621,10 +672,11 @@
end
end
def test_italo_table
+ local_only do
oo = Openoffice.new(File.join("test","simple_spreadsheet_from_italo.ods"))
oo.default_sheet = oo.sheets.first
assert_equal '1', oo.cell('A',1)
assert_equal '1', oo.cell('B',1)
@@ -653,45 +705,47 @@
# 1.0
# Cells values in row 1:
- assert_equal "1:string", oo.cell(1, 1)+":"+oo.celltype(1, 1)
- assert_equal "1:string",oo.cell(1, 2)+":"+oo.celltype(1, 2)
- assert_equal "1:string",oo.cell(1, 3)+":"+oo.celltype(1, 3)
+ assert_equal "1:string", oo.cell(1, 1)+":"+oo.celltype(1, 1).to_s
+ assert_equal "1:string",oo.cell(1, 2)+":"+oo.celltype(1, 2).to_s
+ assert_equal "1:string",oo.cell(1, 3)+":"+oo.celltype(1, 3).to_s
# Cells values in row 2:
- assert_equal "1:string",oo.cell(2, 1)+":"+oo.celltype(2, 1)
- assert_equal "2:string",oo.cell(2, 2)+":"+oo.celltype(2, 2)
- assert_equal "1:string",oo.cell(2, 3)+":"+oo.celltype(2, 3)
+ assert_equal "1:string",oo.cell(2, 1)+":"+oo.celltype(2, 1).to_s
+ assert_equal "2:string",oo.cell(2, 2)+":"+oo.celltype(2, 2).to_s
+ assert_equal "1:string",oo.cell(2, 3)+":"+oo.celltype(2, 3).to_s
# Cells values in row 3:
- assert_equal "1.0:float",oo.cell(3, 1).to_s+":"+oo.celltype(3, 1)
- assert_equal "3.0:float",oo.cell(3, 2).to_s+":"+oo.celltype(3, 2)
- assert_equal "1.0:float",oo.cell(3, 3).to_s+":"+oo.celltype(3, 3)
+ assert_equal "1.0:float",oo.cell(3, 1).to_s+":"+oo.celltype(3, 1).to_s
+ assert_equal "3.0:float",oo.cell(3, 2).to_s+":"+oo.celltype(3, 2).to_s
+ assert_equal "1.0:float",oo.cell(3, 3).to_s+":"+oo.celltype(3, 3).to_s
# Cells values in row 4:
- assert_equal "A:string",oo.cell(4, 1)+":"+oo.celltype(4, 1)
- assert_equal "A:string",oo.cell(4, 2)+":"+oo.celltype(4, 2)
- assert_equal "A:string",oo.cell(4, 3)+":"+oo.celltype(4, 3)
+ assert_equal "A:string",oo.cell(4, 1)+":"+oo.celltype(4, 1).to_s
+ assert_equal "A:string",oo.cell(4, 2)+":"+oo.celltype(4, 2).to_s
+ assert_equal "A:string",oo.cell(4, 3)+":"+oo.celltype(4, 3).to_s
# Cells values in row 5:
- assert_equal "0.01:percentage",oo.cell(5, 1)+":"+oo.celltype(5, 1)
- assert_equal "0.01:percentage",oo.cell(5, 2)+":"+oo.celltype(5, 2)
- assert_equal "0.01:percentage",oo.cell(5, 3)+":"+oo.celltype(5, 3)
+ assert_equal "0.01:percentage",oo.cell(5, 1)+":"+oo.celltype(5, 1).to_s
+ assert_equal "0.01:percentage",oo.cell(5, 2)+":"+oo.celltype(5, 2).to_s
+ assert_equal "0.01:percentage",oo.cell(5, 3)+":"+oo.celltype(5, 3).to_s
+ end
-
end
def test_external1
+ local_only do
if File.exist?(File.join("test","external1.xls"))
oo = Excel.new(File.join("test","external1.xls"))
oo.default_sheet = 2
assert_equal(-105.675, oo.cell('Z',5))
assert_equal(41.31205555, oo.cell('AA',5))
assert_equal(2218.3344, oo.cell('AB',5))
end
+ end
end
def myfunc(n)
puts "#{n} Euro"
end
@@ -714,44 +768,23 @@
[7, 2, "=SUM([.$A$1:.B6])"],
[7, 3, "=[Sheet2.A1]"],
[8, 2, "=SUM([.$A$1:.B7])"],
], oo.formulas
- if DateTime.now > Date.new(2007,6,25)
+ after Date.new(2007,6,25) do
# setting a cell
oo.set('A',15, 41)
assert_equal 41, oo.cell('A',15)
oo.set('A',16, "41")
assert_equal "41", oo.cell('A',16)
oo.set('A',17, 42.5)
assert_equal 42.5, oo.cell('A',17)
end
- if DateTime.now > Date.new(2007,6,30)
- assert_equal 21, oo.solve('a',7)
- end
+ #after Date.new(2007,7,30) do
+ # assert_equal 21, oo.solve('a',7)
+ #end
- oo = Openoffice.new(File.join("test","external1.ods"))
- # each spreadsheet, each row, each column
- oo.sheets.each {|sheet|
- oo.default_sheet = sheet
- if oo.first_row
- oo.first_row.upto(oo.last_row) do |row|
- oo.first_column.upto(oo.last_column) do |col|
- value = oo.cell(row,col)
- # is it a formula?
- if oo.formula?(row,col)
- # formula
- puts oo.formula(row,col)
- # value
- puts value if value
- else
- puts value if value
- end
- end
- end
- end
- }
end
end
def test_borders_sheets
@@ -779,11 +812,13 @@
assert_equal 5, oo.first_column
assert_equal 9, oo.last_column
end
if EXCEL
oo = Excel.new(File.join("test","borders.xls"))
- oo.default_sheet = 2 # oo.sheets[1]
+p oo.sheets
+ p oo.sheets[1]
+ oo.default_sheet = oo.sheets[1]
assert_equal 6, oo.first_row
assert_equal 11, oo.last_row
assert_equal 4, oo.first_column
assert_equal 8, oo.last_column
@@ -829,10 +864,12 @@
yaml_entry(15,4,"float",44.0)+
yaml_entry(15,5,"float",45.0)+
yaml_entry(16,3,"string","dreiundvierzig")+
yaml_entry(16,4,"string","vierundvierzig")+
yaml_entry(16,5,"string","fuenfundvierzig"), oo.to_yaml({}, 12,3)
+ #example: puts oo.to_yaml({}, 12,3)
+ #example: puts oo.to_yaml({"probe" => "bodenproben_2007-06-30"}, 12,3)
end
if EXCEL
oo = Excel.new(File.join("test","numbers1.xls"))
oo.default_sheet = 1
assert_equal "--- \n"+yaml_entry(5,1,"date","1961-11-21"), oo.to_yaml({}, 5,1,5,1)
@@ -853,18 +890,126 @@
yaml_entry(16,4,"string","vierundvierzig")+
yaml_entry(16,5,"string","fuenfundvierzig"), oo.to_yaml({}, 12,3)
end
end
- def test_old_openoffice
- if OPENOFFICE
- oo = Openoffice.new(File.join("/media","LACIE","ferien","Ferien.ods"))
- oo.default_sheet = oo.sheets.first
- assert_equal 2006, oo.cell('A',1)
- assert_equal "Berlin", oo.cell('B',1)
- assert_equal "Herbstferien", oo.cell('C',1)
- assert_equal Date.new(2006,10,2), oo.cell('D',1)
- assert_equal Date.new(2006,10,14), oo.cell('E',1)
+if false
+ def test_soap_server
+ #threads = []
+ #threads << Thread.new("serverthread") do
+ fork do
+ p "serverthread started"
+ puts "in child, pid = #$$"
+ puts `/usr/bin/ruby rooserver.rb`
+ p "serverthread finished"
end
+ #threads << Thread.new("clientthread") do
+ p "clientthread started"
+ sleep 10
+ proxy = SOAP::RPC::Driver.new("http://localhost:12321","spreadsheetserver")
+ #"http://localhost:2222")
+ #"http://pragprog.com/InterestCalc")
+ proxy.add_method('cell','row','col')
+ proxy.add_method('officeversion')
+ proxy.add_method('last_row')
+ proxy.add_method('last_column')
+ proxy.add_method('first_row')
+ proxy.add_method('first_column')
+ proxy.add_method('sheets')
+ proxy.add_method('set_default_sheet','s')
+ proxy.add_method('ferien_fuer_region', 'region')
+
+ sheets = proxy.sheets
+p sheets
+ proxy.set_default_sheet(sheets.first)
+
+ assert_equal 1, proxy.first_row
+ assert_equal 1, proxy.first_column
+ assert_equal 187, proxy.last_row
+ assert_equal 7, proxy.last_column
+ assert_equal 42, proxy.cell('C',8)
+ assert_equal 43, proxy.cell('F',12)
+ assert_equal "1.0", proxy.officeversion
+ p "clientthread finished"
+ #end
+ #threads.each {|t| t.join }
+ puts "fertig"
+ Process.kill("INT",pid)
+ pid=Process.wait
+ puts "child terminated, pid= #{pid}, status= #{$?.exitstatus}"
end
+end # false
+
+ def split_coord(s)
+ letter = ""
+ number = 0
+ i = 0
+ while i<s.length and "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".include?(s[i,1])
+ letter += s[i,1]
+ i+=1
+ end
+ while i<s.length and "01234567890".include?(s[i,1])
+ number = number*10 + s[i,1].to_i
+ i+=1
+ end
+ if letter=="" or number==0
+ raise ArgumentError
+ end
+ return letter,number
+ end
+
+ #def sum(s,expression)
+ # arg = expression.split(':')
+ # b,z = split_coord(arg[0])
+ # first_row = z
+ # first_col = Openoffice.letter_to_number(b)
+ # b,z = split_coord(arg[1])
+ # last_row = z
+ # last_col = Openoffice.letter_to_number(b)
+ # result = 0
+ # first_row.upto(last_row) {|row|
+ # first_col.upto(last_col) {|col|
+ # result = result + s.cell(row,col)
+ # }
+ # }
+ # result
+ #end
+
+ #def test_dsl
+ # s = Openoffice.new(File.join("test","numbers1.ods"))
+ # s.default_sheet = s.sheets.first
+#
+# s.set 'a',1, 5
+# s.set 'b',1, 3
+# s.set 'c',1, 7
+# s.set('a',2, s.cell('a',1)+s.cell('b',1))
+# assert_equal 8, s.cell('a',2)
+#
+# assert_equal 15, sum(s,'A1:C1')
+# end
+
+ #def test_create_spreadsheet1
+ # name=File.join('test','createdspreadsheet.ods')
+ # rm(name) if File.exists?(File.join('test','createdspreadsheet.ods'))
+ # # anlegen, falls noch nicht existierend
+ # s = Openoffice.new(name,true)
+ # assert File.exists?(name)
+ #end
+
+ #def test_create_spreadsheet2
+ # # anlegen, falls noch nicht existierend
+ # s = Openoffice.new(File.join("test","createdspreadsheet.ods"),true)
+ # s.set 'a',1,42
+ # s.set 'b',1,43
+ # s.set 'c',1,44
+ # s.save
+ #
+ # #after Date.new(2007,7,3) do
+ # # t = Openoffice.new(File.join("test","createdspreadsheet.ods"))
+ # # assert_equal 42, t.cell(1,'a')
+ # # assert_equal 43, t.cell('b',1)
+ # # assert_equal 44, t.cell('c',3)
+ # #end
+ #end
+
end # class