test/test_roo.rb in roo-1.2.3 vs test/test_roo.rb in roo-1.3.5
- old
+ new
@@ -6,11 +6,13 @@
#--
# these test cases were developed to run under Linux OS, some commands
# (like 'diff') must be changed (or commented out ;-)) if you want to run
# the tests under another OS
#
-require File.dirname(__FILE__) + '/test_helper.rb'
+
+TESTDIR = File.dirname(__FILE__)
+require TESTDIR + '/test_helper.rb'
#require 'soap/rpc/driver'
require 'fileutils'
require 'timeout'
require 'logger'
$log = Logger.new(File.join(ENV['HOME'],"roo.log"))
@@ -40,21 +42,31 @@
end
class Test::Unit::TestCase
def key_of(spreadsheetname)
begin
+
return {
- 'numbers1' => "o10837434939102457526.4784396906364855777",
- 'borders' => "o10837434939102457526.664868920231926255",
- 'simple_spreadsheet' => "ptu6bbahNZpYe-L1vEBmgGA",
+ 'formula' => 'rt4Pw1WmjxFtyfrqqy94wPw',
+ "write.me" => 'r6m7HFlUOwst0RTUTuhQ0Ow',
+ 'numbers1' => "rYraCzjxTtkxw1NxHJgDU8Q",
+ 'borders' => "r_nLYMft6uWg_PT9Rc2urXw",
+ 'simple_spreadsheet' => "r3aMMCBCA153TmU_wyIaxfw",
'testnichtvorhandenBibelbund.ods' => "invalidkeyforanyspreadsheet", # !!! intentionally false key
- "only_one_sheet" => "o10837434939102457526.762705759906130135",
- "write.me" => 'ptu6bbahNZpY0N0RrxQbWdw&hl',
- 'formula' => 'o10837434939102457526.3022866619437760118',
- 'time-test' => 'ptu6bbahNZpYBMhk01UfXSg',
- 'datetime' => "ptu6bbahNZpYQEtZwzL_dZQ",
+ "only_one_sheet" => "rqRtkcPJ97nhQ0m9ksDw2rA",
+ 'time-test' => 'r2XfDBJMrLPjmuLrPQQrEYw',
+ 'datetime' => "r2kQpXWr6xOSUpw9MyXavYg",
}[spreadsheetname]
+ # 'numbers1' => "o10837434939102457526.4784396906364855777",
+ # 'borders' => "o10837434939102457526.664868920231926255",
+ # 'simple_spreadsheet' => "ptu6bbahNZpYe-L1vEBmgGA",
+ # 'testnichtvorhandenBibelbund.ods' => "invalidkeyforanyspreadsheet", # !!! intentionally false key
+ # "only_one_sheet" => "o10837434939102457526.762705759906130135",
+ # "write.me" => 'ptu6bbahNZpY0N0RrxQbWdw&hl',
+ # 'formula' => 'o10837434939102457526.3022866619437760118',
+ # 'time-test' => 'ptu6bbahNZpYBMhk01UfXSg',
+ # 'datetime' => "ptu6bbahNZpYQEtZwzL_dZQ",
rescue
raise "unknown spreadsheetname: #{spreadsheetname}"
end
end
@@ -104,15 +116,15 @@
end
end
class TestRoo < Test::Unit::TestCase
- OPENOFFICE = true # do Openoffice-Spreadsheet Tests?
- EXCEL = true # do Excel Tests?
- GOOGLE = true # do Google-Spreadsheet Tests?
- GNUMERIC_ODS = false # do gnumeric with ods files Tests?
- EXCELX = true # do Excel-X Tests? (.xlsx-files)
+ OPENOFFICE = true # do Openoffice-Spreadsheet Tests?
+ EXCEL = true # do Excel Tests?
+ GOOGLE = false # do Google-Spreadsheet Tests?
+ GNUMERIC_ODS = false # do gnumeric with ods files Tests?
+ EXCELX = true # do Excel-X Tests? (.xlsx-files)
OPENOFFICEWRITE = false # experimental: write access with OO-Documents
ONLINE = true
LONG_RUN = false
GLOBAL_TIMEOUT = 48.minutes #*60 # 2*12*60 # seconds
@@ -125,39 +137,42 @@
def test_internal_minutes
assert_equal 42*60, 42.minutes
end
+ # Using Date.strptime so check that it's using the method
+ # with the value set in date_format
def test_date
- assert Google.date?("21/11/1962")
- assert_equal Date.new(1962,11,21), Google.to_date("21/11/1962")
-
- assert !Google.date?("21")
- assert_nil Google.to_date("21")
-
- assert !Google.date?("21/11")
- assert_nil Google.to_date("21/11")
-
- assert !Google.date?("Mittwoch/21/1961")
- assert_nil Google.to_date("Mittwoch/21/1961")
+ if GOOGLE
+ oo = Google.new(key_of("numbers1"))
+ # should default to DDMMYYYY
+ assert oo.date?("21/11/1962") == true
+ assert oo.date?("11/21/1962") == false
+ oo.date_format = '%m/%d/%Y'
+ assert oo.date?("21/11/1962") == false
+ assert oo.date?("11/21/1962") == true
+ oo.date_format = '%Y-%m-%d'
+ assert oo.date?("1962-11-21") == true
+ assert oo.date?("1962-21-11") == false
+ end
end
def test_classes
if OPENOFFICE
- oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
assert_kind_of Openoffice, oo
end
if EXCEL
- oo = Excel.new(File.join("test","numbers1.xls"))
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
assert_kind_of Excel, oo
end
if GOOGLE
oo = Google.new(key_of("numbers1"))
assert_kind_of Google, oo
end
if EXCELX
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
assert_kind_of Excelx, oo
end
end
def test_letters
@@ -178,11 +193,11 @@
end
end
def test_sheets_openoffice
if OPENOFFICE
- oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
assert_equal ["Tabelle1","Name of Sheet 2","Sheet3","Sheet4","Sheet5"], oo.sheets
assert_raise(RangeError) {
oo.default_sheet = "no_sheet"
}
assert_raise(TypeError) {
@@ -196,11 +211,11 @@
end
end
def test_sheets_gnumeric_ods
if GNUMERIC_ODS
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
assert_equal ["Tabelle1","Name of Sheet 2","Sheet3","Sheet4","Sheet5"], oo.sheets
assert_raise(RangeError) {
oo.default_sheet = "no_sheet"
}
assert_raise(TypeError) {
@@ -214,11 +229,11 @@
end
end
def test_sheets_excel
if EXCEL
- oo = Excel.new(File.join("test","numbers1.xls"))
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
assert_equal ["Tabelle1","Name of Sheet 2","Sheet3","Sheet4","Sheet5"], oo.sheets
assert_raise(RangeError) {
oo.default_sheet = "no_sheet"
}
assert_raise(TypeError) {
@@ -231,11 +246,11 @@
end
end
def test_sheets_excelx
if EXCELX
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
assert_equal ["Tabelle1","Name of Sheet 2","Sheet3","Sheet4","Sheet5"], oo.sheets
assert_raise(RangeError) {
oo.default_sheet = "no_sheet"
}
assert_raise(TypeError) {
@@ -265,11 +280,11 @@
end
end
def test_cell_openoffice
if OPENOFFICE
- oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"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)
assert_equal 4, oo.cell(1,4)
@@ -304,11 +319,11 @@
end
end
def test_cell_gnumeric_ods
if GNUMERIC_ODS
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_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)
assert_equal 4, oo.cell(1,4)
@@ -343,11 +358,11 @@
end
end
def test_cell_excel
if EXCEL
- oo = Excel.new(File.join("test","numbers1.xls"))
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
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)
@@ -382,11 +397,11 @@
end
end
def test_cell_excelx
if EXCELX
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
oo.default_sheet = oo.sheets.first
assert_kind_of Float, oo.cell(1,1)
assert_equal 1, oo.cell(1,1)
assert_equal 2, oo.cell(1,2)
@@ -435,67 +450,61 @@
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 11, oo.cell(2,7)
- # assert_equal "float", oo.celltype(2,7)
assert_equal :float, oo.celltype(2,7), "Inhalt: --#{oo.cell(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)
assert_equal 14, oo.cell(4,5)
-
assert_equal 10, oo.cell(4,'A')
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.new(1961,11,21), oo.cell(5,1)
assert_equal "1961-11-21", oo.cell(5,1).to_s
end # GOOGLE
end
def test_celltype
###
if OPENOFFICE
- oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
oo.default_sheet = oo.sheets.first
assert_equal :string, oo.celltype(2,6)
end
if GNUMERIC_ODS
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
oo.default_sheet = oo.sheets.first
assert_equal :string, oo.celltype(2,6)
end
if EXCEL
- oo = Excel.new(File.join("test","numbers1.xls"))
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
oo.default_sheet = oo.sheets.first
assert_equal :string, oo.celltype(2,6)
end
if GOOGLE
oo = Google.new(key_of("numbers1"))
oo.default_sheet = oo.sheets.first
assert_equal :string, oo.celltype(2,6)
end
if EXCELX
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
oo.default_sheet = oo.sheets.first
assert_equal :string, oo.celltype(2,6)
end
end
def test_cell_address
if OPENOFFICE
- oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"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')
@@ -516,11 +525,11 @@
assert_equal "thisisd9", oo.cell('d',9)
assert_equal "thisisa11", oo.cell('a',11)
end
if GNUMERIC_ODS
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_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')
@@ -541,11 +550,11 @@
assert_equal "thisisd9", oo.cell('d',9)
assert_equal "thisisa11", oo.cell('a',11)
end
if EXCEL
- oo = Excel.new(File.join("test","numbers1.xls"))
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
oo.default_sheet = oo.sheets.first
assert_equal "tata", oo.cell(6,'A')
assert_equal "tata", oo.cell(6,1)
assert_equal "tata", oo.cell('A',6)
assert_equal "tata", oo.cell(6,'a')
@@ -568,11 +577,11 @@
assert_equal "thisisa11", oo.cell('a',11)
#assert_equal "lulua", oo.cell('b',10)
end
if EXCELX
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
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')
@@ -624,15 +633,15 @@
# Version of the (XML) office document
# please note that "1.0" is returned even if it was created with OpenOffice V. 2.0
def test_officeversion
if OPENOFFICE
- oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
assert_equal "1.0", oo.officeversion
end
if GNUMERIC_ODS
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
assert_equal "1.0", oo.officeversion
end
if EXCEL
# excel does not have a officeversion
end
@@ -646,11 +655,11 @@
end
#TODO: inkonsequente Lieferung Fixnum/Float
def test_rows
if OPENOFFICE
- oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
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)
@@ -662,11 +671,11 @@
assert_equal "vierundvierzig", oo.cell('d',16)
assert_equal "fuenfundvierzig", oo.cell('e',16)
assert_equal ["einundvierzig", "zweiundvierzig", "dreiundvierzig", "vierundvierzig", "fuenfundvierzig"], oo.row(16)
end
if GNUMERIC_ODS
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
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)
@@ -678,11 +687,11 @@
assert_equal "vierundvierzig", oo.cell('d',16)
assert_equal "fuenfundvierzig", oo.cell('e',16)
assert_equal ["einundvierzig", "zweiundvierzig", "dreiundvierzig", "vierundvierzig", "fuenfundvierzig"], oo.row(16)
end
if EXCEL
- oo = Excel.new(File.join("test","numbers1.xls"))
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
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)
@@ -698,11 +707,11 @@
"dreiundvierzig",
"vierundvierzig",
"fuenfundvierzig"], oo.row(16)
end
if EXCELX
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
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)
@@ -741,26 +750,26 @@
end
end
def test_last_row
if OPENOFFICE
- oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
oo.default_sheet = oo.sheets.first
assert_equal 18, oo.last_row
end
if GNUMERIC_ODS
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
oo.default_sheet = oo.sheets.first
assert_equal 18, oo.last_row
end
if EXCEL
- oo = Excel.new(File.join("test","numbers1.xls"))
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
oo.default_sheet = oo.sheets.first
assert_equal 18, oo.last_row
end
if EXCELX
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
oo.default_sheet = oo.sheets.first
assert_equal 18, oo.last_row
end
if GOOGLE
oo = Google.new(key_of("numbers1"))
@@ -769,26 +778,26 @@
end
end
def test_last_column
if OPENOFFICE
- oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
oo.default_sheet = oo.sheets.first
assert_equal 7, oo.last_column
end
if GNUMERIC_ODS
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
oo.default_sheet = oo.sheets.first
assert_equal 7, oo.last_column
end
if EXCEL
- oo = Excel.new(File.join("test","numbers1.xls"))
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
oo.default_sheet = oo.sheets.first
assert_equal 7, oo.last_column
end
if EXCELX
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
oo.default_sheet = oo.sheets.first
assert_equal 7, oo.last_column
end
if GOOGLE
oo = Google.new(key_of("numbers1"))
@@ -797,26 +806,26 @@
end
end
def test_last_column_as_letter
if OPENOFFICE
- oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
oo.default_sheet = oo.sheets.first
assert_equal 'G', oo.last_column_as_letter
end
if GNUMERIC_ODS
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
oo.default_sheet = oo.sheets.first
assert_equal 'G', oo.last_column_as_letter
end
if EXCEL
- oo = Excel.new(File.join("test","numbers1.xls"))
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
oo.default_sheet = 1 # oo.sheets.first
assert_equal 'G', oo.last_column_as_letter
end
if EXCELX
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
oo.default_sheet = oo.sheets.first
assert_equal 'G', oo.last_column_as_letter
end
if GOOGLE
oo = Google.new(key_of("numbers1"))
@@ -825,26 +834,26 @@
end
end
def test_first_row
if OPENOFFICE
- oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
oo.default_sheet = oo.sheets.first
assert_equal 1, oo.first_row
end
if GNUMERIC_ODS
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
oo.default_sheet = oo.sheets.first
assert_equal 1, oo.first_row
end
if EXCEL
- oo = Excel.new(File.join("test","numbers1.xls"))
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
oo.default_sheet = 1 # oo.sheets.first
assert_equal 1, oo.first_row
end
if EXCELX
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
oo.default_sheet = oo.sheets.first
assert_equal 1, oo.first_row
end
if GOOGLE
oo = Google.new(key_of("numbers1"))
@@ -853,26 +862,26 @@
end
end
def test_first_column
if OPENOFFICE
- oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
oo.default_sheet = oo.sheets.first
assert_equal 1, oo.first_column
end
if GNUMERIC_ODS
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
oo.default_sheet = oo.sheets.first
assert_equal 1, oo.first_column
end
if EXCEL
- oo = Excel.new(File.join("test","numbers1.xls"))
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
oo.default_sheet = 1 # oo.sheets.first
assert_equal 1, oo.first_column
end
if EXCELX
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
oo.default_sheet = oo.sheets.first
assert_equal 1, oo.first_column
end
if GOOGLE
assert_nothing_raised(Timeout::Error) {
@@ -885,35 +894,35 @@
end
end
def test_first_column_as_letter_openoffice
if OPENOFFICE
- oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
oo.default_sheet = oo.sheets.first
assert_equal 'A', oo.first_column_as_letter
end
end
def test_first_column_as_letter_gnumeric_ods
if GNUMERIC_ODS
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
oo.default_sheet = oo.sheets.first
assert_equal 'A', oo.first_column_as_letter
end
end
def test_first_column_as_letter_excel
if EXCEL
- oo = Excel.new(File.join("test","numbers1.xls"))
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
oo.default_sheet = 1 # oo.sheets.first
assert_equal 'A', oo.first_column_as_letter
end
end
def test_first_column_as_letter_excelx
if EXCELX
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
oo.default_sheet = oo.sheets.first
assert_equal 'A', oo.first_column_as_letter
end
end
@@ -925,11 +934,11 @@
end
end
def test_sheetname
if OPENOFFICE
- oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
oo.default_sheet = "Name of Sheet 2"
assert_equal 'I am sheet 2', oo.cell('C',5)
assert_raise(RangeError) { oo.default_sheet = "non existing sheet name" }
assert_raise(RangeError) { dummy = oo.cell('C',5,"non existing sheet name")}
assert_raise(RangeError) { dummy = oo.celltype('C',5,"non existing sheet name")}
@@ -939,11 +948,11 @@
assert_raise(RangeError) { dummy = oo.set('C',5,42,"non existing sheet name")}
assert_raise(RangeError) { dummy = oo.formulas("non existing sheet name")}
assert_raise(RangeError) { dummy = oo.to_yaml({},1,1,1,1,"non existing sheet name")}
end
if GNUMERIC_ODS
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
oo.default_sheet = "Name of Sheet 2"
assert_equal 'I am sheet 2', oo.cell('C',5)
assert_raise(RangeError) {
oo.default_sheet = "non existing sheet name"
}
@@ -956,11 +965,11 @@
assert_raise(RangeError) { dummy = oo.set('C',5,42,"non existing sheet name")}
assert_raise(RangeError) { dummy = oo.formulas("non existing sheet name")}
assert_raise(RangeError) { dummy = oo.to_yaml({},1,1,1,1,"non existing sheet name")}
end
if EXCEL
- oo = Excel.new(File.join("test","numbers1.xls"))
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
oo.default_sheet = "Name of Sheet 2"
assert_equal 'I am sheet 2', oo.cell('C',5)
assert_raise(RangeError) {
oo.default_sheet = "non existing sheet name"
}
@@ -973,11 +982,11 @@
#assert_raise(RangeError) { dummy = oo.set('C',5,42,"non existing sheet name")}
#assert_raise(RangeError) { dummy = oo.formulas("non existing sheet name")}
assert_raise(RangeError) { dummy = oo.to_yaml({},1,1,1,1,"non existing sheet name")}
end
if EXCELX
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
oo.default_sheet = "Name of Sheet 2"
assert_equal 'I am sheet 2', oo.cell('C',5)
assert_raise(RangeError) {
oo.default_sheet = "non existing sheet name"
}
@@ -1011,39 +1020,39 @@
end
end
def test_boundaries
if OPENOFFICE
- oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
oo.default_sheet = "Name of Sheet 2"
assert_equal 2, oo.first_column
assert_equal 'B', oo.first_column_as_letter
assert_equal 5, oo.first_row
assert_equal 'E', oo.last_column_as_letter
assert_equal 14, oo.last_row
end
if GNUMERIC_ODS
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
oo.default_sheet = "Name of Sheet 2"
assert_equal 2, oo.first_column
assert_equal 'B', oo.first_column_as_letter
assert_equal 5, oo.first_row
assert_equal 'E', oo.last_column_as_letter
assert_equal 14, oo.last_row
end
if EXCEL
#-- Excel
- oo = Excel.new(File.join("test","numbers1.xls"))
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
oo.default_sheet = 2 # "Name of Sheet 2"
assert_equal 2, oo.first_column
assert_equal 'B', oo.first_column_as_letter
assert_equal 5, oo.first_row
assert_equal 'E', oo.last_column_as_letter
assert_equal 14, oo.last_row
end
if EXCELX
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
oo.default_sheet = "Name of Sheet 2"
assert_equal 2, oo.first_column
assert_equal 'B', oo.first_column_as_letter
assert_equal 5, oo.first_row
assert_equal 'E', oo.last_column_as_letter
@@ -1051,38 +1060,38 @@
end
end
def test_multiple_letters
if OPENOFFICE
- oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
oo.default_sheet = "Sheet3"
assert_equal "i am AA", oo.cell('AA',1)
assert_equal "i am AB", oo.cell('AB',1)
assert_equal "i am BA", oo.cell('BA',1)
assert_equal 'BA', oo.last_column_as_letter
assert_equal "i am BA", oo.cell(1,'BA')
end
if GNUMERIC_ODS
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
oo.default_sheet = "Sheet3"
assert_equal "i am AA", oo.cell('AA',1)
assert_equal "i am AB", oo.cell('AB',1)
assert_equal "i am BA", oo.cell('BA',1)
assert_equal 'BA', oo.last_column_as_letter
assert_equal "i am BA", oo.cell(1,'BA')
end
if EXCEL
- oo = Excel.new(File.join("test","numbers1.xls"))
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
oo.default_sheet = 3 # "Sheet3"
assert_equal "i am AA", oo.cell('AA',1)
assert_equal "i am AB", oo.cell('AB',1)
assert_equal "i am BA", oo.cell('BA',1)
assert_equal 'BA', oo.last_column_as_letter
assert_equal "i am BA", oo.cell(1,'BA')
end
if EXCELX
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
oo.default_sheet = "Sheet3"
assert_equal "i am AA", oo.cell('AA',1)
assert_equal "i am AB", oo.cell('AB',1)
assert_equal "i am BA", oo.cell('BA',1)
assert_equal 'BA', oo.last_column_as_letter
@@ -1090,11 +1099,11 @@
end
end
def test_argument_error
if EXCEL
- oo = Excel.new(File.join("test","numbers1.xls"))
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
before Date.new(2007,7,20) do
assert_raise(ArgumentError) {
#oo.default_sheet = "first sheet"
oo.default_sheet = "Tabelle1"
}
@@ -1107,46 +1116,46 @@
end
end
def test_empty_eh
if OPENOFFICE #-- OpenOffice
- oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
oo.default_sheet = oo.sheets.first
assert oo.empty?('a',14)
assert ! oo.empty?('a',15)
assert oo.empty?('a',20)
end
if GNUMERIC_ODS
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
oo.default_sheet = oo.sheets.first
assert oo.empty?('a',14)
assert ! oo.empty?('a',15)
assert oo.empty?('a',20)
end
if EXCEL
- oo = Excel.new(File.join("test","numbers1.xls"))
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
oo.default_sheet = 1
assert oo.empty?('a',14)
assert ! oo.empty?('a',15)
assert oo.empty?('a',20)
end
if EXCELX
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
oo.default_sheet = oo.sheets.first
assert oo.empty?('a',14)
assert ! oo.empty?('a',15)
assert oo.empty?('a',20)
end
end
def test_writeopenoffice
if OPENOFFICEWRITE
- File.cp(File.join("test","numbers1.ods"),
- File.join("test","numbers2.ods"))
- File.cp(File.join("test","numbers2.ods"),
- File.join("test","bak_numbers2.ods"))
- oo = Openoffice.new(File.join("test","numbers2.ods"))
+ File.cp(File.join(TESTDIR,"numbers1.ods"),
+ File.join(TESTDIR,"numbers2.ods"))
+ File.cp(File.join(TESTDIR,"numbers2.ods"),
+ File.join(TESTDIR,"bak_numbers2.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"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"
@@ -1154,12 +1163,12 @@
end
}
}
oo.save
- oo1 = Openoffice.new(File.join("test","numbers2.ods"))
- oo2 = Openoffice.new(File.join("test","bak_numbers2.ods"))
+ oo1 = Openoffice.new(File.join(TESTDIR,"numbers2.ods"))
+ oo2 = Openoffice.new(File.join(TESTDIR,"bak_numbers2.ods"))
#p oo2.to_s
assert_equal 999, oo2.cell('a',1), oo2.cell('a',1)
assert_equal oo2.cell('a',1) + 7, oo1.cell('a',1)
assert_equal oo2.cell('b',1)+7, oo1.cell('b',1)
assert_equal oo2.cell('c',1)+7, oo1.cell('c',1)
@@ -1168,62 +1177,62 @@
assert_equal oo2.cell('b',2)+7, oo1.cell('b',2)
assert_equal oo2.cell('c',2)+7, oo1.cell('c',2)
assert_equal oo2.cell('d',2)+7, oo1.cell('d',2)
assert_equal oo2.cell('e',2)+7, oo1.cell('e',2)
- File.cp(File.join("test","bak_numbers2.ods"),
- File.join("test","numbers2.ods"))
+ File.cp(File.join(TESTDIR,"bak_numbers2.ods"),
+ File.join(TESTDIR,"numbers2.ods"))
end
end
def test_reload
if OPENOFFICE
- oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
oo.default_sheet = oo.sheets.first
assert_equal 1, oo.cell(1,1)
oo.reload
assert_equal 1, oo.cell(1,1)
end
if GNUMERIC_ODS
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
oo.default_sheet = oo.sheets.first
assert_equal 1, oo.cell(1,1)
oo.reload
assert_equal 1, oo.cell(1,1)
end
if EXCEL
- oo = Excel.new(File.join("test","numbers1.xls"))
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
oo.default_sheet = 1 # oo.sheets.first
assert_equal 1, oo.cell(1,1)
oo.reload
assert_equal 1, oo.cell(1,1)
end
if EXCELX
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
oo.default_sheet = oo.sheets.first
assert_equal 1, oo.cell(1,1)
oo.reload
assert_equal 1, oo.cell(1,1)
end
end
def test_bug_contiguous_cells
if OPENOFFICE
- oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
oo.default_sheet = "Sheet4"
assert_equal Date.new(2007,06,16), oo.cell('a',1)
assert_equal 10, oo.cell('b',1)
assert_equal 10, oo.cell('c',1)
assert_equal 10, oo.cell('d',1)
assert_equal 10, oo.cell('e',1)
end
if GNUMERIC_ODS
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
oo.default_sheet = "Sheet4"
assert_equal Date.new(2007,06,16), oo.cell('a',1)
assert_equal 10, oo.cell('b',1)
assert_equal 10, oo.cell('c',1)
assert_equal 10, oo.cell('d',1)
@@ -1239,47 +1248,47 @@
end
end
def test_bug_italo_ve
if OPENOFFICE
- oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
oo.default_sheet = "Sheet5"
assert_equal 1, oo.cell('A',1)
assert_equal 5, oo.cell('b',1)
assert_equal 5, oo.cell('c',1)
assert_equal 2, oo.cell('a',2)
assert_equal 3, oo.cell('a',3)
end
if OPENOFFICE
- oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
oo.default_sheet = "Sheet5"
assert_equal 1, oo.cell('A',1)
assert_equal 5, oo.cell('b',1)
assert_equal 5, oo.cell('c',1)
assert_equal 2, oo.cell('a',2)
assert_equal 3, oo.cell('a',3)
end
if GNUMERIC_ODS
- oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"gnumeric_numbers1.ods"))
oo.default_sheet = "Sheet5"
assert_equal 1, oo.cell('A',1)
assert_equal 5, oo.cell('b',1)
assert_equal 5, oo.cell('c',1)
assert_equal 2, oo.cell('a',2)
assert_equal 3, oo.cell('a',3)
end
if EXCEL
- oo = Excel.new(File.join("test","numbers1.xls"))
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
oo.default_sheet = 5
assert_equal 1, oo.cell('A',1)
assert_equal 5, oo.cell('b',1)
assert_equal 5, oo.cell('c',1)
assert_equal 2, oo.cell('a',2)
assert_equal 3, oo.cell('a',3)
end
if EXCELX
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
oo.default_sheet = "Sheet5" # oo.sheets[5-1]
assert_equal 1, oo.cell('A',1)
assert_equal 5, oo.cell('b',1)
assert_equal 5, oo.cell('c',1)
assert_equal 2, oo.cell('a',2)
@@ -1297,11 +1306,11 @@
end
#2008-01-30
def test_italo_table
local_only do
- oo = Openoffice.new(File.join("test","simple_spreadsheet_from_italo.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"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)
assert_equal '1', oo.cell('C',1)
@@ -1359,11 +1368,11 @@
# Cells values in row 5:
assert_equal "0.01:percentage",oo.cell(5, 1).to_s+":"+oo.celltype(5, 1).to_s
assert_equal "0.01:percentage",oo.cell(5, 2).to_s+":"+oo.celltype(5, 2).to_s
assert_equal "0.01:percentage",oo.cell(5, 3).to_s+":"+oo.celltype(5, 3).to_s
- oo = Excel.new(File.join("test","simple_spreadsheet_from_italo.xls"))
+ oo = Excel.new(File.join(TESTDIR,"simple_spreadsheet_from_italo.xls"))
oo.default_sheet = oo.sheets.first
assert_equal '1', oo.cell('A',1)
assert_equal '1', oo.cell('B',1)
assert_equal '1', oo.cell('C',1)
@@ -1433,11 +1442,11 @@
end
end
def test_formula_openoffice
if OPENOFFICE
- oo = Openoffice.new(File.join("test","formula.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"formula.ods"))
oo.default_sheet = oo.sheets.first
assert_equal 1, oo.cell('A',1)
assert_equal 2, oo.cell('A',2)
assert_equal 3, oo.cell('A',3)
assert_equal 4, oo.cell('A',4)
@@ -1464,11 +1473,11 @@
end
def test_formula_excel
if defined? excel_supports_formulas
if EXCEL
- oo = Excel.new(File.join("test","formula.xls"))
+ oo = Excel.new(File.join(TESTDIR,"formula.xls"))
oo.default_sheet = oo.sheets.first
assert_equal 1, oo.cell('A',1)
assert_equal 2, oo.cell('A',2)
assert_equal 3, oo.cell('A',3)
assert_equal 4, oo.cell('A',4)
@@ -1534,11 +1543,11 @@
end # GOOGLE
end
def test_formula_excelx
if EXCELX
- oo = Excelx.new(File.join("test","formula.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"formula.xlsx"))
oo.default_sheet = oo.sheets.first
assert_equal 1, oo.cell('A',1)
assert_equal 2, oo.cell('A',2)
assert_equal 3, oo.cell('A',3)
assert_equal 4, oo.cell('A',4)
@@ -1573,11 +1582,11 @@
end
end
def test_borders_sheets_openoffice
if OPENOFFICE
- oo = Openoffice.new(File.join("test","borders.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"borders.ods"))
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
@@ -1596,11 +1605,11 @@
end
end
def test_borders_sheets_excel
if EXCEL
- oo = Excel.new(File.join("test","borders.xls"))
+ oo = Excel.new(File.join(TESTDIR,"borders.xls"))
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
@@ -1619,11 +1628,11 @@
end
end
def test_borders_sheets_excelx
if EXCELX
- oo = Excelx.new(File.join("test","borders.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"borders.xlsx"))
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
@@ -1677,11 +1686,11 @@
"cell_#{row}_#{col}: \n row: #{row} \n col: #{col} \n celltype: #{type} \n value: #{value} \n"
end
def test_to_yaml
if OPENOFFICE
- oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
oo.default_sheet = oo.sheets.first
assert_equal "--- \n"+yaml_entry(5,1,"date","1961-11-21"), oo.to_yaml({}, 5,1,5,1)
assert_equal "--- \n"+yaml_entry(8,3,"string","thisisc8"), oo.to_yaml({}, 8,3,8,3)
assert_equal "--- \n"+yaml_entry(12,3,"float",43.0), oo.to_yaml({}, 12,3,12,3)
assert_equal \
@@ -1700,11 +1709,11 @@
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 = Excel.new(File.join(TESTDIR,"numbers1.xls"))
oo.default_sheet = 1
assert_equal "--- \n"+yaml_entry(5,1,"date","1961-11-21"), oo.to_yaml({}, 5,1,5,1)
assert_equal "--- \n"+yaml_entry(8,3,"string","thisisc8"), oo.to_yaml({}, 8,3,8,3)
assert_equal "--- \n"+yaml_entry(12,3,"float",43.0), oo.to_yaml({}, 12,3,12,3)
assert_equal \
@@ -1721,11 +1730,11 @@
yaml_entry(16,3,"string","dreiundvierzig")+
yaml_entry(16,4,"string","vierundvierzig")+
yaml_entry(16,5,"string","fuenfundvierzig"), oo.to_yaml({}, 12,3)
end
if EXCELX
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
oo.default_sheet = oo.sheets.first
assert_equal "--- \n"+yaml_entry(5,1,"date","1961-11-21"), oo.to_yaml({}, 5,1,5,1)
assert_equal "--- \n"+yaml_entry(8,3,"string","thisisc8"), oo.to_yaml({}, 8,3,8,3)
assert_equal "--- \n"+yaml_entry(12,3,"float",43.0), oo.to_yaml({}, 12,3,12,3)
assert_equal \
@@ -1847,11 +1856,11 @@
# }
# result
#end
#def test_dsl
- # s = Openoffice.new(File.join("test","numbers1.ods"))
+ # s = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
# s.default_sheet = s.sheets.first
#
# s.set 'a',1, 5
# s.set 'b',1, 3
# s.set 'c',1, 7
@@ -1860,58 +1869,58 @@
#
# 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'))
+ # name = File.join(TESTDIR,'createdspreadsheet.ods')
+ # rm(name) if File.exists?(File.join(TESTDIR,'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 = Openoffice.new(File.join(TESTDIR,"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"))
+ # # t = Openoffice.new(File.join(TESTDIR,"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
def test_only_one_sheet
if OPENOFFICE
- oo = Openoffice.new(File.join("test","only_one_sheet.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"only_one_sheet.ods"))
# oo.default_sheet = oo.sheets.first
assert_equal 42, oo.cell('B',4)
assert_equal 43, oo.cell('C',4)
assert_equal 44, oo.cell('D',4)
oo.default_sheet = oo.sheets.first
assert_equal 42, oo.cell('B',4)
assert_equal 43, oo.cell('C',4)
assert_equal 44, oo.cell('D',4)
end
if EXCEL
- oo = Excel.new(File.join("test","only_one_sheet.xls"))
+ oo = Excel.new(File.join(TESTDIR,"only_one_sheet.xls"))
# oo.default_sheet = oo.sheets.first
assert_equal 42, oo.cell('B',4)
assert_equal 43, oo.cell('C',4)
assert_equal 44, oo.cell('D',4)
oo.default_sheet = oo.sheets.first
assert_equal 42, oo.cell('B',4)
assert_equal 43, oo.cell('C',4)
assert_equal 44, oo.cell('D',4)
end
if EXCELX
- oo = Excelx.new(File.join("test","only_one_sheet.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"only_one_sheet.xlsx"))
# oo.default_sheet = oo.sheets.first
assert_equal 42, oo.cell('B',4)
assert_equal 43, oo.cell('C',4)
assert_equal 44, oo.cell('D',4)
oo.default_sheet = oo.sheets.first
@@ -1936,10 +1945,11 @@
def test_excel_open_from_uri_and_zipped
if EXCEL
if ONLINE
url = 'http://stiny-leonhard.de/bode-v1.xls.zip'
excel = Excel.new(url, :zip)
+ excel.default_sheet = excel.sheets.first
assert_equal 'ist "e" im Nenner von H(s)', excel.cell('b', 5)
excel.remove_tmp # don't forget to remove the temporary files
end
end
end
@@ -1973,11 +1983,11 @@
def test_excel_zipped
after Date.new(2009,1,10) do
if EXCEL
$log.level = Logger::DEBUG
- excel = Excel.new(File.join("test","bode-v1.xls.zip"), :zip)
+ excel = Excel.new(File.join(TESTDIR,"bode-v1.xls.zip"), :zip)
assert excel
# muss Fehler bringen, weil kein default_sheet gesetzt wurde
assert_raises (ArgumentError) {
assert_equal 'ist "e" im Nenner von H(s)', excel.cell('b', 5)
}
@@ -1992,11 +2002,11 @@
def test_excelx_zipped
# TODO: bode...xls bei Gelegenheit nach .xlsx konverieren lassen und zippen!
if EXCELX
after Date.new(2999,7,30) do
# diese Datei gibt es noch nicht gezippt
- excel = Excelx.new(File.join("test","bode-v1.xlsx.zip"), :zip)
+ excel = Excelx.new(File.join(TESTDIR,"bode-v1.xlsx.zip"), :zip)
assert excel
assert_raises (ArgumentError) {
assert_equal 'ist "e" im Nenner von H(s)', excel.cell('b', 5)
}
excel.default_sheet = excel.sheets.first
@@ -2006,11 +2016,11 @@
end
end
def test_openoffice_zipped
if OPENOFFICE
- oo = Openoffice.new(File.join("test","bode-v1.ods.zip"), :zip)
+ oo = Openoffice.new(File.join(TESTDIR,"bode-v1.ods.zip"), :zip)
assert oo
# muss Fehler bringen, weil kein default_sheet gesetzt wurde
assert_raises (ArgumentError) {
assert_equal 'ist "e" im Nenner von H(s)', oo.cell('b', 5)
@@ -2021,11 +2031,11 @@
end
end
def test_bug_ric
if OPENOFFICE
- oo = Openoffice.new(File.join("test","ric.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"ric.ods"))
oo.default_sheet = oo.sheets.first
assert oo.empty?('A',1)
assert oo.empty?('B',1)
assert oo.empty?('C',1)
assert oo.empty?('D',1)
@@ -2089,18 +2099,18 @@
end
end
def test_mehrteilig
if OPENOFFICE
- oo = Openoffice.new(File.join("test","Bibelbund1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"Bibelbund1.ods"))
oo.default_sheet = oo.sheets.first
assert_equal "Tagebuch des Sekret\303\244rs. Letzte Tagung 15./16.11.75 Schweiz", oo.cell(45,'A')
end
#if EXCELX
# after Date.new(2008,6,1) do
# #Datei gibt es noch nicht
- # oo = Excelx.new(File.join("test","Bibelbund1.xlsx"))
+ # oo = Excelx.new(File.join(TESTDIR,"Bibelbund1.xlsx"))
# oo.default_sheet = oo.sheets.first
# assert_equal "Tagebuch des Sekret\303\244rs. Letzte Tagung 15./16.11.75 Schweiz", oo.cell(45,'A')
# end
#end
end
@@ -2109,11 +2119,11 @@
if LONG_RUN
if OPENOFFICE
assert_nothing_raised(Timeout::Error) {
Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
File.delete_if_exist("/tmp/Bibelbund.csv")
- oo = Openoffice.new(File.join("test","Bibelbund.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"Bibelbund.ods"))
oo.default_sheet = oo.sheets.first
assert_equal "Tagebuch des Sekret\303\244rs. Letzte Tagung 15./16.11.75 Schweiz", oo.cell(45,'A')
assert_equal "Tagebuch des Sekret\303\244rs. Nachrichten aus Chile", oo.cell(46,'A')
assert_equal "Tagebuch aus Chile Juli 1977", oo.cell(55,'A')
assert oo.to_csv("/tmp/Bibelbund.csv")
@@ -2129,11 +2139,11 @@
if LONG_RUN
if EXCEL
assert_nothing_raised(Timeout::Error) {
Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
File.delete_if_exist("/tmp/Bibelbund.csv")
- oo = Excel.new(File.join("test","Bibelbund.xls"))
+ oo = Excel.new(File.join(TESTDIR,"Bibelbund.xls"))
oo.default_sheet = oo.sheets.first
assert oo.to_csv("/tmp/Bibelbund.csv")
assert File.exists?("/tmp/Bibelbund.csv")
assert_equal "", `diff test/Bibelbund.csv /tmp/Bibelbund.csv`
end
@@ -2147,11 +2157,11 @@
if LONG_RUN
if EXCELX
assert_nothing_raised(Timeout::Error) {
Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
File.delete_if_exist("/tmp/Bibelbund.csv")
- oo = Excelx.new(File.join("test","Bibelbund.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"Bibelbund.xlsx"))
oo.default_sheet = oo.sheets.first
assert oo.to_csv("/tmp/Bibelbund.csv")
assert File.exists?("/tmp/Bibelbund.csv")
assert_equal "", `diff test/Bibelbund.csv /tmp/Bibelbund.csv`
end
@@ -2183,11 +2193,11 @@
def test_to_csv_openoffice
if OPENOFFICE
#assert_nothing_raised(Timeout::Error) {
Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
File.delete_if_exist("/tmp/numbers1.csv")
- oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
# bug?, 2008-01-15 from Troy Davis
assert oo.to_csv("/tmp/numbers1.csv",oo.sheets.first)
assert File.exists?("/tmp/numbers1.csv")
@@ -2206,11 +2216,11 @@
def test_to_csv_excel
if EXCEL
#assert_nothing_raised(Timeout::Error) {
Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
File.delete_if_exist("/tmp/numbers1_excel.csv")
- oo = Excel.new(File.join("test","numbers1.xls"))
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
# bug?, 2008-01-15 from Troy Davis
assert oo.to_csv("/tmp/numbers1_excel.csv",oo.sheets.first)
assert File.exists?("/tmp/numbers1_excel.csv")
assert_equal "", `diff test/numbers1_excel.csv /tmp/numbers1_excel.csv`
@@ -2227,11 +2237,11 @@
def test_to_csv_excelx
if EXCELX
#assert_nothing_raised(Timeout::Error) {
Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
File.delete_if_exist("/tmp/numbers1.csv")
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
# bug?, 2008-01-15 from Troy Davis
assert oo.to_csv("/tmp/numbers1.csv",oo.sheets.first)
assert File.exists?("/tmp/numbers1.csv")
assert_equal "", `diff test/numbers1.csv /tmp/numbers1.csv`
@@ -2254,25 +2264,25 @@
oo = Google.new(key_of('numbers1'))
oo.default_sheet = oo.sheets.first
assert oo.to_csv("/tmp/numbers1.csv")
assert File.exists?("/tmp/numbers1.csv")
- assert_equal "", `diff test/numbers1.csv /tmp/numbers1.csv`
+ assert_equal "", `diff #{File.join(TESTDIR,"numbers1.csv")} /tmp/numbers1.csv`
# bug?, 2008-01-15 from Troy Davis
assert oo.to_csv("/tmp/numbers1.csv",oo.sheets.first)
assert File.exists?("/tmp/numbers1.csv")
- assert_equal "", `diff test/numbers1.csv /tmp/numbers1.csv`
+ assert_equal "", `diff #{File.join(TESTDIR,"numbers1.csv")} /tmp/numbers1.csv`
end # Timeout
#} # nothing_raised
end # GOOGLE
end
def test_bug_mehrere_datum
if OPENOFFICE
- oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
oo.default_sheet = 'Sheet5'
assert_equal :date, oo.celltype('A',4)
assert_equal :date, oo.celltype('B',4)
assert_equal :date, oo.celltype('C',4)
assert_equal :date, oo.celltype('D',4)
@@ -2303,11 +2313,11 @@
assert_equal "ABC", oo.cell('D',6)
assert_equal "ABC", oo.cell('E',6)
end # Openoffice
if EXCEL
- oo = Excel.new(File.join("test","numbers1.xls"))
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
oo.default_sheet = 'Sheet5'
assert_equal :date, oo.celltype('A',4)
assert_equal :date, oo.celltype('B',4)
assert_equal :date, oo.celltype('C',4)
assert_equal :date, oo.celltype('D',4)
@@ -2337,11 +2347,11 @@
assert_equal "ABC", oo.cell('C',6)
assert_equal "ABC", oo.cell('D',6)
assert_equal "ABC", oo.cell('E',6)
end # Excel
if EXCELX
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
oo.default_sheet = 'Sheet5'
assert_equal :date, oo.celltype('A',4)
assert_equal :date, oo.celltype('B',4)
assert_equal :date, oo.celltype('C',4)
assert_equal :date, oo.celltype('D',4)
@@ -2374,11 +2384,11 @@
end # Excelx
end
def test_multiple_sheets
if OPENOFFICE
- oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
2.times do
oo.default_sheet = "Tabelle1"
assert_equal 1, oo.cell(1,1)
assert_equal 1, oo.cell(1,1,"Tabelle1")
assert_equal "I am sheet 2", oo.cell('C',5,"Name of Sheet 2")
@@ -2418,11 +2428,11 @@
end # OPENOFFICE
if EXCEL
$debug = true
- oo = Excel.new(File.join("test","numbers1.xls"))
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
2.times do
oo.default_sheet = "Tabelle1"
assert_equal 1, oo.cell(1,1)
assert_equal 1, oo.cell(1,1,"Tabelle1")
assert_equal "I am sheet 2", oo.cell('C',5,"Name of Sheet 2")
@@ -2501,11 +2511,11 @@
assert_equal "ABC", oo.cell('E',6,sheetname)
oo.reload
end
end
if EXCELX
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
2.times do
oo.default_sheet = "Tabelle1"
assert_equal 1, oo.cell(1,1)
assert_equal 1, oo.cell(1,1,"Tabelle1")
assert_equal "I am sheet 2", oo.cell('C',5,"Name of Sheet 2")
@@ -2546,22 +2556,22 @@
end
def test_bug_empty_sheet_openoffice
if OPENOFFICE
- oo = Openoffice.new(File.join("test","formula.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"formula.ods"))
oo.default_sheet = 'Sheet3' # is an empty sheet
assert_nothing_raised(NoMethodError) {
oo.to_csv(File.join("/","tmp","emptysheet.csv"))
}
assert_equal "", `cat /tmp/emptysheet.csv`
end
end
def test_bug_empty_sheet_excelx
if EXCELX
- oo = Excelx.new(File.join("test","formula.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"formula.xlsx"))
oo.default_sheet = 'Sheet3' # is an empty sheet
assert_nothing_raised(NoMethodError) {
oo.to_csv(File.join("/","tmp","emptysheet.csv"))
}
assert_equal "", `cat /tmp/emptysheet.csv`
@@ -2570,11 +2580,11 @@
def test_find_by_row_huge_document_openoffice
if LONG_RUN
if OPENOFFICE
Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
- oo = Openoffice.new(File.join("test","Bibelbund.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"Bibelbund.ods"))
oo.default_sheet = oo.sheets.first
rec = oo.find 20
assert rec
# assert_equal "Brief aus dem Sekretariat", rec[0]
#p rec
@@ -2591,11 +2601,11 @@
def test_find_by_row_huge_document_excel
if LONG_RUN
if EXCEL
Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
- oo = Excel.new(File.join("test","Bibelbund.xls"))
+ oo = Excel.new(File.join(TESTDIR,"Bibelbund.xls"))
oo.default_sheet = oo.sheets.first
rec = oo.find 20
assert rec
#jetzt als Hash assert_equal "Brief aus dem Sekretariat", rec[0]
assert_equal "Brief aus dem Sekretariat", rec[0]['TITEL']
@@ -2611,11 +2621,11 @@
def test_find_by_row_huge_document_excelx
if LONG_RUN
if EXCEL
Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
- oo = Excelx.new(File.join("test","Bibelbund.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"Bibelbund.xlsx"))
oo.default_sheet = oo.sheets.first
rec = oo.find 20
assert rec
assert_equal "Brief aus dem Sekretariat", rec[0]['TITEL']
@@ -2627,11 +2637,11 @@
end
end
def test_find_by_row_openoffice
if OPENOFFICE
- oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
oo.default_sheet = oo.sheets.first
oo.header_line = nil
rec = oo.find 16
assert rec
assert_nil oo.header_line
@@ -2645,11 +2655,11 @@
end
end
def test_find_by_row_excel
if EXCEL
- oo = Excel.new(File.join("test","numbers1.xls"))
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
oo.default_sheet = oo.sheets.first
oo.header_line = nil
rec = oo.find 16
assert rec
# keine Headerlines in diesem Beispiel definiert
@@ -2661,11 +2671,11 @@
end
end
def test_find_by_row_excelx
if EXCELX
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
oo.default_sheet = oo.sheets.first
oo.header_line = nil
rec = oo.find 16
assert rec
# keine Headerlines in diesem Beispiel definiert
@@ -2714,11 +2724,11 @@
def test_find_by_conditions_openoffice
if LONG_RUN
if OPENOFFICE
assert_nothing_raised(Timeout::Error) {
Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
- oo = Openoffice.new(File.join("test","Bibelbund.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"Bibelbund.ods"))
oo.default_sheet = oo.sheets.first
#-----------------------------------------------------------------
zeilen = oo.find(:all, :conditions => {
'TITEL' => 'Brief aus dem Sekretariat'
}
@@ -2807,11 +2817,11 @@
def test_find_by_conditions_excel
if LONG_RUN
if EXCEL
assert_nothing_raised(Timeout::Error) {
Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
- oo = Excel.new(File.join("test","Bibelbund.xls"))
+ oo = Excel.new(File.join(TESTDIR,"Bibelbund.xls"))
oo.default_sheet = oo.sheets.first
#-----------------------------------------------------------------
zeilen = oo.find(:all, :conditions => {
'TITEL' => 'Brief aus dem Sekretariat'
}
@@ -2868,11 +2878,11 @@
end
end
#TODO: temporaerer Test
def test_seiten_als_date
- oo = Excelx.new(File.join("test","Bibelbund.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"Bibelbund.xlsx"))
oo.default_sheet = oo.sheets.first
assert_equal 'Bericht aus dem Sekretariat', oo.cell(13,1)
assert_equal '1981-4', oo.cell(13,'D')
assert_equal [:numeric_or_formula,"General"], oo.excelx_type(13,'E')
assert_equal '428', oo.excelx_value(13,'E')
@@ -2882,11 +2892,11 @@
def test_find_by_conditions_excelx
if LONG_RUN
if EXCELX
assert_nothing_raised(Timeout::Error) {
Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
- oo = Excelx.new(File.join("test","Bibelbund.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"Bibelbund.xlsx"))
oo.default_sheet = oo.sheets.first
#-----------------------------------------------------------------
zeilen = oo.find(:all, :conditions => {
'TITEL' => 'Brief aus dem Sekretariat'
}
@@ -3040,11 +3050,11 @@
after Date.new(2008,9,30) do
expected = [1.0,5.0,nil,10.0,Date.new(1961,11,21),'tata',nil,nil,nil,nil,'thisisa11',41.0,nil,nil,41.0,'einundvierzig',nil,Date.new(2007,5,31)]
if OPENOFFICE
Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
- oo = Openoffice.new(File.join('test','numbers1.ods'))
+ oo = Openoffice.new(File.join(TESTDIR,'numbers1.ods'))
oo.default_sheet = oo.sheets.first
assert_equal expected, oo.column(1)
assert_equal expected, oo.column('a')
end
end
@@ -3053,11 +3063,11 @@
def test_column_excel
expected = [1.0,5.0,nil,10.0,Date.new(1961,11,21),'tata',nil,nil,nil,nil,'thisisa11',41.0,nil,nil,41.0,'einundvierzig',nil,Date.new(2007,5,31)]
if EXCEL
Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
- oo = Excel.new(File.join('test','numbers1.xls'))
+ oo = Excel.new(File.join(TESTDIR,'numbers1.xls'))
oo.default_sheet = oo.sheets.first
assert_equal expected, oo.column(1)
assert_equal expected, oo.column('a')
end
end
@@ -3065,11 +3075,11 @@
def test_column_excelx
expected = [1.0,5.0,nil,10.0,Date.new(1961,11,21),'tata',nil,nil,nil,nil,'thisisa11',41.0,nil,nil,41.0,'einundvierzig',nil,Date.new(2007,5,31)]
if EXCELX
Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
- oo = Excelx.new(File.join('test','numbers1.xlsx'))
+ oo = Excelx.new(File.join(TESTDIR,'numbers1.xlsx'))
oo.default_sheet = oo.sheets.first
assert_equal expected, oo.column(1)
assert_equal expected, oo.column('a')
end
end
@@ -3090,11 +3100,11 @@
def test_column_huge_document_openoffice
if LONG_RUN
if OPENOFFICE
assert_nothing_raised(Timeout::Error) {
Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
- oo = Openoffice.new(File.join('test','Bibelbund.ods'))
+ oo = Openoffice.new(File.join(TESTDIR,'Bibelbund.ods'))
oo.default_sheet = oo.sheets.first
assert_equal 3735, oo.column('a').size
#assert_equal 499, oo.column('a').size
end
}
@@ -3105,11 +3115,11 @@
def test_column_huge_document_excel
if LONG_RUN
if EXCEL
assert_nothing_raised(Timeout::Error) {
Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
- oo = Excel.new(File.join('test','Bibelbund.xls'))
+ oo = Excel.new(File.join(TESTDIR,'Bibelbund.xls'))
oo.default_sheet = oo.sheets.first
assert_equal 3735, oo.column('a').size
#assert_equal 499, oo.column('a').size
end
}
@@ -3120,11 +3130,11 @@
def test_column_huge_document_excelx
if LONG_RUN
if EXCELX
assert_nothing_raised(Timeout::Error) {
Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
- oo = Excelx.new(File.join('test','Bibelbund.xlsx'))
+ oo = Excelx.new(File.join(TESTDIR,'Bibelbund.xlsx'))
oo.default_sheet = oo.sheets.first
assert_equal 3735, oo.column('a').size
#assert_equal 499, oo.column('a').size
end
}
@@ -3148,11 +3158,11 @@
end
end
end
def test_simple_spreadsheet_find_by_condition_openoffice
- oo = Openoffice.new(File.join("test","simple_spreadsheet.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"simple_spreadsheet.ods"))
oo.default_sheet = oo.sheets.first
oo.header_line = 3
erg = oo.find(:all, :conditions => {'Comment' => 'Task 1'})
assert_equal Date.new(2007,05,07), erg[1]['Date']
assert_equal 10.75 , erg[1]['Start time']
@@ -3163,11 +3173,11 @@
end
def test_simple_spreadsheet_find_by_condition_excel
if EXCEL
$debug = true
- oo = Excel.new(File.join("test","simple_spreadsheet.xls"))
+ oo = Excel.new(File.join(TESTDIR,"simple_spreadsheet.xls"))
oo.default_sheet = oo.sheets.first
oo.header_line = 3
erg = oo.find(:all, :conditions => {'Comment' => 'Task 1'})
assert_equal Date.new(2007,05,07), erg[1]['Date']
assert_equal 10.75 , erg[1]['Start time']
@@ -3181,11 +3191,11 @@
end
def test_simple_spreadsheet_find_by_condition_excelx
if EXCELX
# die dezimalen Seiten bekomme ich seltsamerweise als Date
- oo = Excelx.new(File.join("test","simple_spreadsheet.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"simple_spreadsheet.xlsx"))
oo.default_sheet = oo.sheets.first
oo.header_line = 3
erg = oo.find(:all, :conditions => {'Comment' => 'Task 1'})
#expected = { "Start time"=>10.75,
# "Pause"=>0.0,
@@ -3217,10 +3227,11 @@
def test_simple_spreadsheet_find_by_condition_google
if GOOGLE
oo = Google.new(key_of("simple_spreadsheet"))
oo.default_sheet = oo.sheets.first
oo.header_line = 3
+ oo.date_format = '%m/%d/%Y'
erg = oo.find(:all, :conditions => {'Comment' => 'Task 1'})
assert_equal Date.new(2007,05,07), erg[1]['Date']
assert_equal 10.75 , erg[1]['Start time']
assert_equal 12.50 , erg[1]['End time']
assert_equal 0 , erg[1]['Pause']
@@ -3229,11 +3240,11 @@
assert_equal "Task 1" , erg[1]['Comment']
end
end
def DONT_test_false_encoding
- ex = Excel.new(File.join('test','false_encoding.xls'))
+ ex = Excel.new(File.join(TESTDIR,'false_encoding.xls'))
ex.default_sheet = ex.sheets.first
assert_equal "Sheet1", ex.sheets.first
ex.first_row.upto(ex.last_row) do |row|
ex.first_column.upto(ex.last_column) do |col|
content = ex.cell(row,col)
@@ -3248,11 +3259,11 @@
end
def test_bug_false_borders_with_formulas
if EXCEL
after Date.new(2008,9,15) do
- ex = Excel.new(File.join('test','false_encoding.xls'))
+ ex = Excel.new(File.join(TESTDIR,'false_encoding.xls'))
ex.default_sheet = ex.sheets.first
#assert_equal 1, ex.first_row
=begin
korrigiert auf Zeile 2. Zeile 1 enthaelt nur Formeln, die in parseexcel nicht
ausgewertet werden koennen. D. h. der Nutzer hat keinen Vorteil davon, wenn
@@ -3268,11 +3279,11 @@
end
end
end
def test_fe
- ex = Excel.new(File.join('test','false_encoding.xls'))
+ ex = Excel.new(File.join(TESTDIR,'false_encoding.xls'))
ex.default_sheet = ex.sheets.first
#DOES NOT WORK IN EXCEL FILES: assert_equal Date.new(2007,11,1), ex.cell('a',1)
#DOES NOT WORK IN EXCEL FILES: assert_equal true, ex.formula?('a',1)
#DOES NOT WORK IN EXCEL FILES: assert_equal '=TODAY()', ex.formula('a',1)
@@ -3294,11 +3305,11 @@
assert_equal 'R4', ex.cell('D',3)
end
def test_excel_does_not_support_formulas
if EXCEL
- ex = Excel.new(File.join('test','false_encoding.xls'))
+ ex = Excel.new(File.join(TESTDIR,'false_encoding.xls'))
ex.default_sheet = ex.sheets.first
assert_raise(RuntimeError) {
void = ex.formula('a',1)
}
assert_raise(RuntimeError) {
@@ -3340,23 +3351,23 @@
" First column: A\n"+
" Last column: E"
if OPENOFFICE
ext = ".ods"
expected = sprintf(expected_templ,ext)
- oo = Openoffice.new(File.join("test","numbers1.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.ods"))
assert_equal expected, oo.info
end
if EXCEL
ext = ".xls"
expected = sprintf(expected_templ,ext)
- oo = Excel.new(File.join("test","numbers1.xls"))
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
assert_equal expected, oo.info
end
if EXCELX
ext = ".xlsx"
expected = sprintf(expected_templ,ext)
- oo = Excelx.new(File.join("test","numbers1.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xlsx"))
assert_equal expected, oo.info
end
if GOOGLE
ext = ""
expected = sprintf(expected_templ,ext)
@@ -3366,11 +3377,11 @@
end
end
def test_bug_excel_numbers1_sheet5_last_row
if EXCEL
- oo = Excel.new(File.join("test","numbers1.xls"))
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xls"))
oo.default_sheet = "Tabelle1"
assert_equal 1, oo.first_row
assert_equal 18, oo.last_row
assert_equal Openoffice.letter_to_number('A'), oo.first_column
assert_equal Openoffice.letter_to_number('G'), oo.last_column
@@ -3412,16 +3423,14 @@
assert_raise(IOError) {
oo = Excelx.new(File.join('testnichtvorhanden','Bibelbund.xlsx'))
}
end
if GOOGLE
- after Date.new(2009,1,15) do
- assert_raise(IOError) {
- # oo = Google.new(key_of('testnichtvorhanden'+'Bibelbund.ods'))
- oo = Google.new('testnichtvorhanden')
- }
- end
+ # assert_raise(Net::HTTPServerException) {
+ # oo = Google.new(key_of('testnichtvorhanden'+'Bibelbund.ods'))
+# oo = Google.new('testnichtvorhanden')
+# }
end
end
def test_bug_cell_no_default_sheet
if GOOGLE
@@ -3436,24 +3445,25 @@
end
def test_write_google
# write.me: http://spreadsheets.google.com/ccc?key=ptu6bbahNZpY0N0RrxQbWdw&hl=en_GB
if GOOGLE
- oo = Google.new('ptu6bbahNZpY0N0RrxQbWdw')
+ oo = Google.new(key_of('write.me'))
oo.default_sheet = oo.sheets.first
oo.set_value(1,1,"hello from the tests")
- #oo.set_value(1,1,"sin(1)")
assert_equal "hello from the tests", oo.cell(1,1)
+ oo.set_value(1,1, 1.0)
+ assert_equal 1.0, oo.cell(1,1)
end
end
def test_bug_set_value_with_more_than_one_sheet_google
# write.me: http://spreadsheets.google.com/ccc?key=ptu6bbahNZpY0N0RrxQbWdw&hl=en_GB
if GOOGLE
content1 = 'AAA'
content2 = 'BBB'
- oo = Google.new('ptu6bbahNZpY0N0RrxQbWdw')
+ oo = Google.new(key_of('write.me'))
oo.default_sheet = oo.sheets.first
oo.set_value(1,1,content1)
oo.default_sheet = oo.sheets[1]
oo.set_value(1,1,content2) # in the second sheet
oo.default_sheet = oo.sheets.first
@@ -3465,11 +3475,11 @@
def test_set_value_with_sheet_argument_google
if GOOGLE
random_row = rand(10)+1
random_column = rand(10)+1
- oo = Google.new('ptu6bbahNZpY0N0RrxQbWdw')
+ oo = Google.new(key_of('write.me'))
oo.default_sheet = oo.sheets.first
content1 = 'ABC'
content2 = 'DEF'
oo.set_value(random_row,random_column,content1,oo.sheets.first)
oo.set_value(random_row,random_column,content2,oo.sheets[1])
@@ -3487,11 +3497,11 @@
}
end # GOOGLE
end
def test_bug_bbu_openoffice
- oo = Openoffice.new(File.join('test','bbu.ods'))
+ oo = Openoffice.new(File.join(TESTDIR,'bbu.ods'))
assert_nothing_raised() {
assert_equal "File: bbu.ods
Number of sheets: 3
Sheets: 2007_12, Tabelle2, Tabelle3
Sheet 1:
@@ -3512,11 +3522,11 @@
assert_nil oo.last_column
end
def test_bug_bbu_excel
if EXCEL
- oo = Excel.new(File.join('test','bbu.xls'))
+ oo = Excel.new(File.join(TESTDIR,'bbu.xls'))
assert_nothing_raised() {
assert_equal "File: bbu.xls
Number of sheets: 3
Sheets: 2007_12, Tabelle2, Tabelle3
Sheet 1:
@@ -3538,11 +3548,11 @@
end
end
def test_bug_bbu_excelx
if EXCELX
- oo = Excelx.new(File.join('test','bbu.xlsx'))
+ oo = Excelx.new(File.join(TESTDIR,'bbu.xlsx'))
assert_nothing_raised() {
assert_equal "File: bbu.xlsx
Number of sheets: 3
Sheets: 2007_12, Tabelle2, Tabelle3
Sheet 1:
@@ -3591,11 +3601,11 @@
end
end # false
def test_bug_time_nil_openoffice
if OPENOFFICE
- oo = Openoffice.new(File.join("test","time-test.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"time-test.ods"))
oo.default_sheet = oo.sheets.first
assert_equal 12*3600+13*60+14, oo.cell('B',1) # 12:13:14 (secs since midnight)
assert_equal :time, oo.celltype('B',1)
assert_equal 15*3600+16*60, oo.cell('C',1) # 15:16 (secs since midnight)
assert_equal :time, oo.celltype('C',1)
@@ -3605,11 +3615,11 @@
end
end
def test_bug_time_nil_excel
if EXCEL
- oo = Excel.new(File.join("test","time-test.xls"))
+ oo = Excel.new(File.join(TESTDIR,"time-test.xls"))
oo.default_sheet = oo.sheets.first
assert_equal 12*3600+13*60+14, oo.cell('B',1) # 12:13:14 (secs since midnight)
assert_equal :time, oo.celltype('B',1)
assert_equal 15*3600+16*60, oo.cell('C',1) # 15:16 (secs since midnight)
assert_equal :time, oo.celltype('C',1)
@@ -3619,11 +3629,11 @@
end
end
def test_bug_time_nil_excelx
if EXCELX
- oo = Excelx.new(File.join("test","time-test.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"time-test.xlsx"))
oo.default_sheet = oo.sheets.first
assert_equal [:numeric_or_formula, "hh:mm:ss"],oo.excelx_type('b',1)
assert_in_delta 0.50918981481481485, oo.excelx_value('b', 1), 0.000001
assert_equal :time, oo.celltype('B',1)
assert_equal 12*3600+13*60+14, oo.cell('B',1) # 12:13:14 (secs since midnight)
@@ -3651,11 +3661,11 @@
end
def test_date_time_to_csv_openoffice
if OPENOFFICE
File.delete_if_exist("/tmp/time-test.csv")
- oo = Openoffice.new(File.join("test","time-test.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"time-test.ods"))
oo.default_sheet = oo.sheets.first
assert oo.to_csv("/tmp/time-test.csv")
assert File.exists?("/tmp/time-test.csv")
assert_equal "", `diff test/time-test.csv /tmp/time-test.csv`
end # OPENOFFICE
@@ -3664,11 +3674,11 @@
def test_date_time_to_csv_excel
if EXCEL
#ueberfluessige leere Zeilen werden am Ende noch angehaengt
# last_row fehlerhaft?
File.delete_if_exist("/tmp/time-test.csv")
- oo = Excel.new(File.join("test","time-test.xls"))
+ oo = Excel.new(File.join(TESTDIR,"time-test.xls"))
oo.default_sheet = oo.sheets.first
assert oo.to_csv("/tmp/time-test.csv")
assert File.exists?("/tmp/time-test.csv")
assert_equal "", `diff test/time-test.csv /tmp/time-test.csv`
end # EXCEL
@@ -3677,11 +3687,11 @@
def test_date_time_to_csv_excelx
if EXCELX
#ueberfluessige leere Zeilen werden am Ende noch angehaengt
# last_row fehlerhaft?
File.delete_if_exist("/tmp/time-test.csv")
- oo = Excelx.new(File.join("test","time-test.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"time-test.xlsx"))
oo.default_sheet = oo.sheets.first
assert oo.to_csv("/tmp/time-test.csv")
assert File.exists?("/tmp/time-test.csv")
assert_equal "", `diff test/time-test.csv /tmp/time-test.csv`
end # EXCELX
@@ -3692,39 +3702,39 @@
File.delete_if_exist("/tmp/time-test.csv")
oo = Google.new(key_of("time-test"))
oo.default_sheet = oo.sheets.first
assert oo.to_csv("/tmp/time-test.csv")
assert File.exists?("/tmp/time-test.csv")
- assert_equal "", `diff test/time-test.csv /tmp/time-test.csv`
+ assert_equal "", `diff #{File.join(TESTDIR,"time-test.csv")} /tmp/time-test.csv`
end # GOOGLE
end
def test_date_time_yaml_openoffice
if OPENOFFICE
expected =
"--- \ncell_1_1: \n row: 1 \n col: 1 \n celltype: string \n value: Mittags: \ncell_1_2: \n row: 1 \n col: 2 \n celltype: time \n value: 12:13:14 \ncell_1_3: \n row: 1 \n col: 3 \n celltype: time \n value: 15:16:00 \ncell_1_4: \n row: 1 \n col: 4 \n celltype: time \n value: 23:00:00 \ncell_2_1: \n row: 2 \n col: 1 \n celltype: date \n value: 2007-11-21 \n"
- oo = Openoffice.new(File.join("test","time-test.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"time-test.ods"))
oo.default_sheet = oo.sheets.first
assert_equal expected, oo.to_yaml
end
end
def test_date_time_yaml_excel
if EXCEL
expected =
"--- \ncell_1_1: \n row: 1 \n col: 1 \n celltype: string \n value: Mittags: \ncell_1_2: \n row: 1 \n col: 2 \n celltype: time \n value: 12:13:14 \ncell_1_3: \n row: 1 \n col: 3 \n celltype: time \n value: 15:16:00 \ncell_1_4: \n row: 1 \n col: 4 \n celltype: time \n value: 23:00:00 \ncell_2_1: \n row: 2 \n col: 1 \n celltype: date \n value: 2007-11-21 \n"
- oo = Excel.new(File.join("test","time-test.xls"))
+ oo = Excel.new(File.join(TESTDIR,"time-test.xls"))
oo.default_sheet = oo.sheets.first
assert_equal expected, oo.to_yaml
end
end
def test_date_time_yaml_excelx
if EXCELX
expected =
"--- \ncell_1_1: \n row: 1 \n col: 1 \n celltype: string \n value: Mittags: \ncell_1_2: \n row: 1 \n col: 2 \n celltype: time \n value: 12:13:14 \ncell_1_3: \n row: 1 \n col: 3 \n celltype: time \n value: 15:16:00 \ncell_1_4: \n row: 1 \n col: 4 \n celltype: time \n value: 23:00:00 \ncell_2_1: \n row: 2 \n col: 1 \n celltype: date \n value: 2007-11-21 \n"
- oo = Excelx.new(File.join("test","time-test.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"time-test.xlsx"))
oo.default_sheet = oo.sheets.first
assert_equal expected, oo.to_yaml
end
end
@@ -3739,27 +3749,27 @@
end
def test_no_remaining_tmp_files_openoffice
if OPENOFFICE
assert_raise(Zip::ZipError) { #TODO: besseres Fehlerkriterium bei
- # oo = Openoffice.new(File.join("test","no_spreadsheet_file.txt"))
+ # oo = Openoffice.new(File.join(TESTDIR,"no_spreadsheet_file.txt"))
# es soll absichtlich ein Abbruch provoziert werden, deshalb :ignore
- oo = Openoffice.new(File.join("test","no_spreadsheet_file.txt"),
+ oo = Openoffice.new(File.join(TESTDIR,"no_spreadsheet_file.txt"),
false,
:ignore)
}
a=Dir.glob("oo_*")
assert_equal [], a
end
end
def test_no_remaining_tmp_files_excel
if EXCEL
- assert_raise(OLE::UnknownFormatError) {
- # oo = Excel.new(File.join("test","no_spreadsheet_file.txt"))
+ assert_raise(Ole::Storage::FormatError) {
+ # oo = Excel.new(File.join(TESTDIR,"no_spreadsheet_file.txt"))
# es soll absichtlich ein Abbruch provoziert werden, deshalb :ignore
- oo = Excel.new(File.join("test","no_spreadsheet_file.txt"),
+ oo = Excel.new(File.join(TESTDIR,"no_spreadsheet_file.txt"),
false,
:ignore)
}
a=Dir.glob("oo_*")
assert_equal [], a
@@ -3768,13 +3778,13 @@
def test_no_remaining_tmp_files_excelx
if EXCELX
assert_raise(Zip::ZipError) { #TODO: besseres Fehlerkriterium bei
- # oo = Excelx.new(File.join("test","no_spreadsheet_file.txt"))
+ # oo = Excelx.new(File.join(TESTDIR,"no_spreadsheet_file.txt"))
# es soll absichtlich ein Abbruch provoziert werden, deshalb :ignore
- oo = Excelx.new(File.join("test","no_spreadsheet_file.txt"),
+ oo = Excelx.new(File.join(TESTDIR,"no_spreadsheet_file.txt"),
false,
:ignore)
}
a=Dir.glob("oo_*")
@@ -3812,11 +3822,11 @@
end
def do_test_xml(oo)
assert_nothing_raised {oo.to_xml}
sheetname = oo.sheets.first
- doc = REXML::Document.new(oo.to_xml)
+ doc = XML::Parser.string(oo.to_xml).parse
doc.root.each_element {|xml_sheet|
all_cells = init_all_cells(oo, sheetname)
x = 0
assert_equal sheetname, xml_sheet.attributes['name']
xml_sheet.each_element {|cell|
@@ -3826,11 +3836,11 @@
all_cells[x][:type],
]
result = [
cell.attributes['row'],
cell.attributes['column'],
- cell.text,
+ cell.content,
cell.attributes['type'],
]
assert_equal expected, result
x += 1
} # end of sheet
@@ -3838,48 +3848,48 @@
}
end
def test_to_xml_openoffice
if OPENOFFICE
- oo = Openoffice.new(File.join('test','numbers1.ods'))
+ oo = Openoffice.new(File.join(TESTDIR,'numbers1.ods'))
do_test_xml(oo)
end
end
def test_to_xml_excel
if EXCEL
- oo = Excel.new(File.join('test','numbers1.xls'))
+ oo = Excel.new(File.join(TESTDIR,'numbers1.xls'))
do_test_xml(oo)
end
end
def test_to_xml_excelx
if EXCELX
- oo = Excelx.new(File.join('test','numbers1.xlsx'))
+ oo = Excelx.new(File.join(TESTDIR,'numbers1.xlsx'))
do_test_xml(oo)
end
end
def test_to_xml_google
if GOOGLE
- oo = Google.new(key_of(File.join('test','numbers1.xlsx')))
+ oo = Google.new(key_of(File.join(TESTDIR,'numbers1.xlsx')))
do_test_xml(oo)
end
end
- def test_invalid_iconv_from_ms
+ def SKIP_test_invalid_iconv_from_ms
#TODO: does only run within a darwin-environment
if RUBY_PLATFORM.downcase =~ /darwin/
assert_nothing_raised() {
- oo = Excel.new(File.join("test","ms.xls"))
+ oo = Excel.new(File.join(TESTDIR,"ms.xls"))
}
end
end
def test_bug_row_column_fixnum_float
if EXCEL
- ex = Excel.new(File.join('test','bug-row-column-fixnum-float.xls'))
+ ex = Excel.new(File.join(TESTDIR,'bug-row-column-fixnum-float.xls'))
ex.default_sheet = ex.sheets.first
assert_equal 42.5, ex.cell('b',2)
assert_equal 43 , ex.cell('c',2)
assert_equal ['hij',42.5, 43], ex.row(2)
assert_equal ['def',42.5, 'nop'], ex.column(2)
@@ -3896,11 +3906,11 @@
'King','Dominant','Dominant Slick','Blunt','Clash',
'Bullet','Tadashi Fuse','Jussi','Royale','S-Series',
'Fish','Love','Feelgood ES','Feelgood','GTwin','Troop',
'Lux','Stigma','Feather','Stria','Alpha','Feelgood ICS']
result = []
- @e = Excel.new(File.join('test',"problem.xls"))
+ @e = Excel.new(File.join(TESTDIR,"problem.xls"))
@e.sheets[2..@e.sheets.length].each do |s|
#(13..13).each do |s|
@e.default_sheet = s
name = @e.cell(2,'C')
result << name
@@ -3915,11 +3925,11 @@
def test_bug_c2_parseexcel
after Date.new(2009,1,10) do
local_only do
#-- this is OK
- @workbook = Spreadsheet::ParseExcel.parse(File.join('test',"problem.xls"))
+ @workbook = Spreadsheet::ParseExcel.parse(File.join(TESTDIR,"problem.xls"))
worksheet = @workbook.worksheet(11)
skip = 0
line = 1
row = 2
col = 3
@@ -3933,11 +3943,11 @@
assert_equal "Air", cell.to_s('utf-8')
end
line += 1
}
#-- worksheet 12 does not work
- @workbook = Spreadsheet::ParseExcel.parse(File.join('test',"problem.xls"))
+ @workbook = Spreadsheet::ParseExcel.parse(File.join(TESTDIR,"problem.xls"))
worksheet = @workbook.worksheet(12)
skip = 0
line = 1
row = 2
col = 3
@@ -3964,11 +3974,11 @@
'King','Dominant','Dominant Slick','Blunt','Clash',
'Bullet','Tadashi Fuse','Jussi','Royale','S-Series',
'Fish','Love','Feelgood ES','Feelgood','GTwin','Troop',
'Lux','Stigma','Feather','Stria','Alpha','Feelgood ICS']
result = []
- @e = Excelx.new(File.join('test',"problem.xlsx"))
+ @e = Excelx.new(File.join(TESTDIR,"problem.xlsx"))
@e.sheets[2..@e.sheets.length].each do |s|
@e.default_sheet = s
# assert_equal "A.",@e.cell('a',13)
name = @e.cell(2,'C')
result << name
@@ -3977,11 +3987,11 @@
#assert_equal "Vapor (sheet: Vapor)", "#{name} (sheet: #{@e.sheets.first})"
assert @e.cell(2,'c')
end
assert_equal expected, result
- @e = Excelx.new(File.join('test',"problem.xlsx"))
+ @e = Excelx.new(File.join(TESTDIR,"problem.xlsx"))
#@e.sheets[2..@e.sheets.length].each do |s|
(13..13).each do |s|
@e.default_sheet = s
name = @e.cell(2,'C')
#puts "#{name} (sheet: #{s})"
@@ -3994,12 +4004,12 @@
def test_compare_csv_excelx_excel
if EXCELX
after Date.new(2008,12,30) do
# parseexcel bug
local_only do
- s1 = Excel.new(File.join("test","problem.xls"))
- s2 = Excelx.new(File.join("test","problem.xlsx"))
+ s1 = Excel.new(File.join(TESTDIR,"problem.xls"))
+ s2 = Excelx.new(File.join(TESTDIR,"problem.xlsx"))
s1.sheets.each {|sh| #TODO:
s1.default_sheet = sh
s2.default_sheet = sh
File.delete_if_exist("/tmp/problem.csv")
File.delete_if_exist("/tmp/problemx.csv")
@@ -4019,12 +4029,12 @@
if EXCEL
local_only do
# wieder eingelesene CSV-Datei aus obigem Test
# muss identisch mit problem.xls sein
# Importieren aus csv-Datei muss manuell gemacht werden
- ex = Excel.new(File.join("test","problem.xls"))
- cs = Excel.new(File.join("test","problemx_csv_imported.xls"))
+ ex = Excel.new(File.join(TESTDIR,"problem.xls"))
+ cs = Excel.new(File.join(TESTDIR,"problemx_csv_imported.xls"))
# nur das erste sheet betrachten
ex.default_sheet = ex.sheets.first
cs.default_sheet = cs.sheets.first
ex.first_row.upto(ex.last_row) do |row|
ex.first_column.upto(ex.last_column) do |col|
@@ -4053,119 +4063,119 @@
end
end
def test_file_warning_default
if OPENOFFICE
- assert_raises(TypeError) { oo = Openoffice.new(File.join("test","numbers1.xls")) }
- assert_raises(TypeError) { oo = Openoffice.new(File.join("test","numbers1.xlsx")) }
+ assert_raises(TypeError) { oo = Openoffice.new(File.join(TESTDIR,"numbers1.xls")) }
+ assert_raises(TypeError) { oo = Openoffice.new(File.join(TESTDIR,"numbers1.xlsx")) }
assert_equal [], Dir.glob("oo_*")
end
if EXCEL
- assert_raises(TypeError) { oo = Excel.new(File.join("test","numbers1.ods")) }
- assert_raises(TypeError) { oo = Excel.new(File.join("test","numbers1.xlsx")) }
+ assert_raises(TypeError) { oo = Excel.new(File.join(TESTDIR,"numbers1.ods")) }
+ assert_raises(TypeError) { oo = Excel.new(File.join(TESTDIR,"numbers1.xlsx")) }
assert_equal [], Dir.glob("oo_*")
end
if EXCELX
- assert_raises(TypeError) { oo = Excelx.new(File.join("test","numbers1.ods")) }
- assert_raises(TypeError) { oo = Excelx.new(File.join("test","numbers1.xls")) }
+ assert_raises(TypeError) { oo = Excelx.new(File.join(TESTDIR,"numbers1.ods")) }
+ assert_raises(TypeError) { oo = Excelx.new(File.join(TESTDIR,"numbers1.xls")) }
assert_equal [], Dir.glob("oo_*")
end
end
def test_file_warning_error
if OPENOFFICE
- assert_raises(TypeError) { oo = Openoffice.new(File.join("test","numbers1.xls"),false,:error) }
- assert_raises(TypeError) { oo = Openoffice.new(File.join("test","numbers1.xlsx"),false,:error) }
+ assert_raises(TypeError) { oo = Openoffice.new(File.join(TESTDIR,"numbers1.xls"),false,:error) }
+ assert_raises(TypeError) { oo = Openoffice.new(File.join(TESTDIR,"numbers1.xlsx"),false,:error) }
assert_equal [], Dir.glob("oo_*")
end
if EXCEL
- assert_raises(TypeError) { oo = Excel.new(File.join("test","numbers1.ods"),false,:error) }
- assert_raises(TypeError) { oo = Excel.new(File.join("test","numbers1.xlsx"),false,:error) }
+ assert_raises(TypeError) { oo = Excel.new(File.join(TESTDIR,"numbers1.ods"),false,:error) }
+ assert_raises(TypeError) { oo = Excel.new(File.join(TESTDIR,"numbers1.xlsx"),false,:error) }
assert_equal [], Dir.glob("oo_*")
end
if EXCELX
- assert_raises(TypeError) { oo = Excelx.new(File.join("test","numbers1.ods"),false,:error) }
- assert_raises(TypeError) { oo = Excelx.new(File.join("test","numbers1.xls"),false,:error) }
+ assert_raises(TypeError) { oo = Excelx.new(File.join(TESTDIR,"numbers1.ods"),false,:error) }
+ assert_raises(TypeError) { oo = Excelx.new(File.join(TESTDIR,"numbers1.xls"),false,:error) }
assert_equal [], Dir.glob("oo_*")
end
end
def test_file_warning_warning
if OPENOFFICE
assert_nothing_raised(TypeError) {
assert_raises(Zip::ZipError) {
- oo = Openoffice.new(File.join("test","numbers1.xls"),false, :warning)
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.xls"),false, :warning)
}
}
assert_nothing_raised(TypeError) {
assert_raises(Errno::ENOENT) {
- oo = Openoffice.new(File.join("test","numbers1.xlsx"),false, :warning)
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.xlsx"),false, :warning)
}
}
assert_equal [], Dir.glob("oo_*")
end
if EXCEL
assert_nothing_raised(TypeError) {
- assert_raises(OLE::UnknownFormatError) {
- oo = Excel.new(File.join("test","numbers1.ods"),false, :warning) }
+ assert_raises(Ole::Storage::FormatError) {
+ oo = Excel.new(File.join(TESTDIR,"numbers1.ods"),false, :warning) }
}
assert_nothing_raised(TypeError) {
- assert_raises(OLE::UnknownFormatError) {
- oo = Excel.new(File.join("test","numbers1.xlsx"),false, :warning) }
+ assert_raises(Ole::Storage::FormatError) {
+ oo = Excel.new(File.join(TESTDIR,"numbers1.xlsx"),false, :warning) }
}
assert_equal [], Dir.glob("oo_*")
end
if EXCELX
assert_nothing_raised(TypeError) {
assert_raises(Errno::ENOENT) {
- oo = Excelx.new(File.join("test","numbers1.ods"),false, :warning) }
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.ods"),false, :warning) }
}
assert_nothing_raised(TypeError) {
assert_raises(Zip::ZipError) {
- oo = Excelx.new(File.join("test","numbers1.xls"),false, :warning) }
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xls"),false, :warning) }
}
assert_equal [], Dir.glob("oo_*")
end
end
def test_file_warning_ignore
if OPENOFFICE
assert_nothing_raised(TypeError) {
assert_raises(Zip::ZipError) {
- oo = Openoffice.new(File.join("test","numbers1.xls"),false, :ignore) }
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.xls"),false, :ignore) }
}
assert_nothing_raised(TypeError) {
assert_raises(Errno::ENOENT) {
- oo = Openoffice.new(File.join("test","numbers1.xlsx"),false, :ignore) }
+ oo = Openoffice.new(File.join(TESTDIR,"numbers1.xlsx"),false, :ignore) }
}
assert_equal [], Dir.glob("oo_*")
end
if EXCEL
assert_nothing_raised(TypeError) {
- assert_raises(OLE::UnknownFormatError) {
- oo = Excel.new(File.join("test","numbers1.ods"),false, :ignore) }
+ assert_raises(Ole::Storage::FormatError) {
+ oo = Excel.new(File.join(TESTDIR,"numbers1.ods"),false, :ignore) }
}
assert_nothing_raised(TypeError) {
- assert_raises(OLE::UnknownFormatError) {oo = Excel.new(File.join("test","numbers1.xlsx"),false, :ignore) }}
+ assert_raises(Ole::Storage::FormatError) {oo = Excel.new(File.join(TESTDIR,"numbers1.xlsx"),false, :ignore) }}
assert_equal [], Dir.glob("oo_*")
end
if EXCELX
assert_nothing_raised(TypeError) {
assert_raises(Errno::ENOENT) {
- oo = Excelx.new(File.join("test","numbers1.ods"),false, :ignore)
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.ods"),false, :ignore)
}
}
assert_nothing_raised(TypeError) {
assert_raises(Zip::ZipError) {
- oo = Excelx.new(File.join("test","numbers1.xls"),false, :ignore)
+ oo = Excelx.new(File.join(TESTDIR,"numbers1.xls"),false, :ignore)
}
}
assert_equal [], Dir.glob("oo_*")
end
end
- def test_open_from_uri
+ def SKIP_test_open_from_uri
if ONLINE
if OPENOFFICE
assert_raises(RuntimeError) {
oo = Openoffice.new("http://gibbsnichtdomainxxxxx.com/file.ods")
}
@@ -4183,19 +4193,19 @@
end
end
def test_bug_last_row_excel
if EXCEL
- oo = Excel.new(File.join("test","time-test.xls"))
+ oo = Excel.new(File.join(TESTDIR,"time-test.xls"))
oo.default_sheet = oo.sheets.first
assert_equal 2, oo.last_row
end
end
def test_bug_to_xml_with_empty_sheets_openoffice
if OPENOFFICE
- oo = Openoffice.new(File.join("test","emptysheets.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"emptysheets.ods"))
oo.sheets.each { |sheet|
oo.default_sheet = sheet
assert_equal nil, oo.first_row, "first_row not nil in sheet #{sheet}"
assert_equal nil, oo.last_row, "last_row not nil in sheet #{sheet}"
assert_equal nil, oo.first_column, "first_column not nil in sheet #{sheet}"
@@ -4211,11 +4221,11 @@
end
end
def test_bug_to_xml_with_empty_sheets_excel
if EXCEL
- oo = Excel.new(File.join("test","emptysheets.xls"))
+ oo = Excel.new(File.join(TESTDIR,"emptysheets.xls"))
oo.sheets.each { |sheet|
oo.default_sheet = sheet
assert_equal nil, oo.first_row, "first_row not nil in sheet #{sheet}"
assert_equal nil, oo.last_row, "last_row not nil in sheet #{sheet}"
assert_equal nil, oo.first_column, "first_column not nil in sheet #{sheet}"
@@ -4232,11 +4242,11 @@
end
def test_bug_to_xml_with_empty_sheets_excelx
# kann ich nicht testen, da ich selbst keine .xlsx Files anlegen kann
if EXCELX
- # oo = Excelx.new(File.join("test","emptysheets.xlsx"))
+ # oo = Excelx.new(File.join(TESTDIR,"emptysheets.xlsx"))
# oo.sheets.each { |sheet|
# oo.default_sheet = sheet
# assert_equal nil, oo.first_row, "first_row not nil in sheet #{sheet}"
# assert_equal nil, oo.last_row, "last_row not nil in sheet #{sheet}"
# assert_equal nil, oo.first_column, "first_column not nil in sheet #{sheet}"
@@ -4255,11 +4265,11 @@
def test_bug_simple_spreadsheet_time_bug
# really a bug? are cells really of type time?
# No! :float must be the correct type
if EXCELX
- oo = Excelx.new(File.join("test","simple_spreadsheet.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"simple_spreadsheet.xlsx"))
oo.default_sheet = oo.sheets.first
# puts oo.cell('B',5).to_s
# assert_equal :time, oo.celltype('B',5)
assert_equal :float, oo.celltype('B',5)
assert_equal 10.75, oo.cell('B',5)
@@ -4274,11 +4284,11 @@
def test_to_ascii_openoffice
if OPENOFFICE
after Date.new(9999,12,31) do
- oo = Openoffice.new(File.join("test","verysimple_spreadsheet.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"verysimple_spreadsheet.ods"))
oo.default_sheet = oo.sheets.first
expected="
A | B | C |
-------+-------+------|
7| 8| 9|
@@ -4294,11 +4304,11 @@
end
def test_simple2_excelx
if EXCELX
after Date.new(2008,8,2) do
- oo = Excelx.new(File.join("test","simple_spreadsheet.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"simple_spreadsheet.xlsx"))
oo.default_sheet = oo.sheets.first
assert_equal [:numeric_or_formula, "yyyy\\-mm\\-dd"], oo.excelx_type('A',4)
assert_equal [:numeric_or_formula, "#,##0.00"], oo.excelx_type('B',4)
assert_equal [:numeric_or_formula, "#,##0.00"], oo.excelx_type('c',4)
assert_equal [:numeric_or_formula, "General"], oo.excelx_type('d',4)
@@ -4331,19 +4341,19 @@
def test_possible_bug_snowboard_borders
after Date.new(2008,12,15) do
local_only do
if EXCEL
- ex = Excel.new(File.join('test','problem.xls'))
+ ex = Excel.new(File.join(TESTDIR,'problem.xls'))
ex.default_sheet = ex.sheets.first
assert_equal 2, ex.first_row
assert_equal 30, ex.last_row
assert_equal 'A', ex.first_column_as_letter
assert_equal 'J', ex.last_column_as_letter
end
if EXCELX
- ex = Excelx.new(File.join('test','problem.xlsx'))
+ ex = Excelx.new(File.join(TESTDIR,'problem.xlsx'))
ex.default_sheet = ex.sheets.first
assert_equal 2, ex.first_row
assert_equal 30, ex.last_row
assert_equal 'A', ex.first_column_as_letter
assert_equal 'J', ex.last_column_as_letter
@@ -4370,17 +4380,17 @@
def test_possible_bug_snowboard_cells
local_only do
after Date.new(2009,1,6) do
# warten auf Bugfix in parseexcel
if EXCEL
- ex = Excel.new(File.join('test','problem.xls'))
+ ex = Excel.new(File.join(TESTDIR,'problem.xls'))
ex.default_sheet = 'Custom X'
common_possible_bug_snowboard_cells(ex)
end
end
if EXCELX
- ex = Excelx.new(File.join('test','problem.xlsx'))
+ ex = Excelx.new(File.join(TESTDIR,'problem.xlsx'))
ex.default_sheet = 'Custom X'
common_possible_bug_snowboard_cells(ex)
end
end
end
@@ -4593,11 +4603,11 @@
Even stranger is if I save this file as ".XLS" and parse it the cells parse out fine as they are treated as
'string' instead of 'date'.
This attached file is the newer format of Microsoft Excel (.xlsx).
=end
- xx = Excelx.new(File.join('test','sample_file_2008-09-13.xlsx'))
+ xx = Excelx.new(File.join(TESTDIR,'sample_file_2008-09-13.xlsx'))
assert_equal 1, xx.sheets.size
assert_equal 1, xx.first_row
assert_equal 9, xx.last_row # 9 ist richtig. Es sind zwar 44 Zeilen definiert, aber der Rest hat keinen Inhalt
assert_equal 1, xx.first_column
@@ -4627,11 +4637,11 @@
end
end
end
def do_datetime_tests(oo)
- val = oo.cell('c',3)
+ val = oo.cell('c',3)
assert_kind_of DateTime, val
assert_equal :datetime, oo.celltype('c',3)
assert_equal DateTime.new(1961,11,21,12,17,18), val
val = oo.cell('a',1)
assert_kind_of Date, val
@@ -4656,27 +4666,27 @@
assert_equal Date.new(1961,11,21), oo.cell('c',7)
end
def test_datetime_openoffice
if OPENOFFICE
- oo = Openoffice.new(File.join("test","datetime.ods"))
+ oo = Openoffice.new(File.join(TESTDIR,"datetime.ods"))
oo.default_sheet = oo.sheets.first
do_datetime_tests(oo)
end
end
def test_datetime_excel
if EXCEL
- oo = Excel.new(File.join("test","datetime.xls"))
+ oo = Excel.new(File.join(TESTDIR,"datetime.xls"))
oo.default_sheet = oo.sheets.first
do_datetime_tests(oo)
end
end
def test_datetime_excelx
if EXCELX
- oo = Excelx.new(File.join("test","datetime.xlsx"))
+ oo = Excelx.new(File.join(TESTDIR,"datetime.xlsx"))
oo.default_sheet = oo.sheets.first
do_datetime_tests(oo)
end
end
@@ -4802,15 +4812,15 @@
end
end
# Eine Spreadsheetdatei wird nicht als Dateiname sondern direkt als Dokument
# geoeffnettest_problemx_csv_imported
- def test_from_stream_openoffice
+ def SKIP_test_from_stream_openoffice
after Date.new(2009,1,6) do
if OPENOFFICE
filecontent = nil
- File.open(File.join("test","numbers1.ods")) do |f|
+ File.open(File.join(TESTDIR,"numbers1.ods")) do |f|
filecontent = f.read
p filecontent.class
p filecontent.size
#p filecontent
assert filecontent.size > 0
@@ -4821,13 +4831,162 @@
end
end
end
- def test_bug_encoding_exported_from_google
+ def SKIP_test_bug_encoding_exported_from_google
if EXCEL
- xl = Excel.new(File.join("test","numbers1_from_google.xls"))
+ xl = Excel.new(File.join(TESTDIR,"numbers1_from_google.xls"))
xl.default_sheet = xl.sheets.first
assert_equal 'test', xl.cell(2,'F')
end
end
+
+ def test_cell_openoffice_html_escape
+ if OPENOFFICE
+ oo = Openoffice.new(File.join(TESTDIR,"html-escape.ods"))
+ oo.default_sheet = oo.sheets.first
+ assert_equal "'", oo.cell(1,1)
+ assert_equal "&", oo.cell(2,1)
+ assert_equal ">", oo.cell(3,1)
+ assert_equal "<", oo.cell(4,1)
+ assert_equal "`", oo.cell(5,1)
+ # test_openoffice_zipped catches the "
+ end
+ end
+
+ def test_cell_boolean
+ if EXCEL
+ oo = Excel.new(File.join(TESTDIR,"boolean.xls"))
+ oo.default_sheet = oo.sheets.first
+ assert_equal "true", oo.cell(1,1)
+ assert_equal "false", oo.cell(2,1)
+ end
+ if OPENOFFICE
+ oo = Openoffice.new(File.join(TESTDIR,"boolean.ods"))
+ oo.default_sheet = oo.sheets.first
+ assert_equal "true", oo.cell(1,1)
+ assert_equal "false", oo.cell(2,1)
+ end
+ if EXCELX
+ oo = Excelx.new(File.join(TESTDIR,"boolean.xlsx"))
+ oo.default_sheet = oo.sheets.first
+ assert_equal "TRUE", oo.cell(1,1)
+ assert_equal "FALSE", oo.cell(2,1)
+ end
+ end
+
+ def test_cell_multiline
+ if EXCEL
+ oo = Excel.new(File.join(TESTDIR,"paragraph.xls"))
+ oo.default_sheet = oo.sheets.first
+ assert_equal "This is a test\nof a multiline\nCell", oo.cell(1,1)
+ assert_equal "This is a test\n¶\nof a multiline\n\nCell", oo.cell(1,2)
+ assert_equal "first p\n\nsecond p\n\nlast p", oo.cell(2,1)
+ end
+ if OPENOFFICE
+ oo = Openoffice.new(File.join(TESTDIR,"paragraph.ods"))
+ oo.default_sheet = oo.sheets.first
+ assert_equal "This is a test\nof a multiline\nCell", oo.cell(1,1)
+ assert_equal "This is a test\n¶\nof a multiline\n\nCell", oo.cell(1,2)
+ assert_equal "first p\n\nsecond p\n\nlast p", oo.cell(2,1)
+ end
+ if EXCELX
+ oo = Excelx.new(File.join(TESTDIR,"paragraph.xlsx"))
+ oo.default_sheet = oo.sheets.first
+ assert_equal "This is a test\nof a multiline\nCell", oo.cell(1,1)
+ assert_equal "This is a test\n¶\nof a multiline\n\nCell", oo.cell(1,2)
+ assert_equal "first p\n\nsecond p\n\nlast p", oo.cell(2,1)
+ end
+ end
+
+
+ # for test_cell_styles
+ def verify_cell_fonts(oo)
+ oo.default_sheet = oo.sheets.first
+
+ # bold
+ assert_equal true, oo.font(1,1).bold?
+ assert_equal false, oo.font(1,1).italic?
+ assert_equal false, oo.font(1,1).underline?
+
+ # italic
+ assert_equal false, oo.font(2,1).bold?
+ assert_equal true, oo.font(2,1).italic?
+ assert_equal false, oo.font(2,1).underline?
+
+ # normal
+ assert_equal false, oo.font(3,1).bold?
+ assert_equal false, oo.font(3,1).italic?
+ assert_equal false, oo.font(3,1).underline?
+
+ # underline
+ assert_equal false, oo.font(4,1).bold?
+ assert_equal false, oo.font(4,1).italic?
+ assert_equal true, oo.font(4,1).underline?
+
+ # bold italic
+ assert_equal true, oo.font(5,1).bold?
+ assert_equal true, oo.font(5,1).italic?
+ assert_equal false, oo.font(5,1).underline?
+
+ # bold underline
+ assert_equal true, oo.font(6,1).bold?
+ assert_equal false, oo.font(6,1).italic?
+ assert_equal true, oo.font(6,1).underline?
+
+ # italic underline
+ assert_equal false, oo.font(7,1).bold?
+ assert_equal true, oo.font(7,1).italic?
+ assert_equal true, oo.font(7,1).underline?
+
+ # bolded row
+ assert_equal true, oo.font(8,1).bold?
+ assert_equal false, oo.font(8,1).italic?
+ assert_equal false, oo.font(8,1).underline?
+
+ # bolded col
+ assert_equal true, oo.font(9,2).bold?
+ assert_equal false, oo.font(9,2).italic?
+ assert_equal false, oo.font(9,2).underline?
+
+ # bolded row, italic col
+ assert_equal true, oo.font(10,3).bold?
+ assert_equal true, oo.font(10,3).italic?
+ assert_equal false, oo.font(10,3).underline?
+
+ # normal
+ assert_equal false, oo.font(11,4).bold?
+ assert_equal false, oo.font(11,4).italic?
+ assert_equal false, oo.font(11,4).underline?
+ end
+
+ def test_cell_styles
+ if OPENOFFICE
+ oo = Openoffice.new(File.join(TESTDIR,"style.ods"))
+ verify_cell_fonts(oo)
+ end
+ if EXCELX
+ oo = Excelx.new(File.join(TESTDIR,"style.xlsx"))
+ verify_cell_fonts(oo)
+ end
+ if EXCEL
+ oo = Excel.new(File.join(TESTDIR,"style.xls"))
+ verify_cell_fonts(oo)
+ end
+ end
+
+ # If a cell has a date-like string but is preceeded by a '
+ # to force that date to be treated like a string, we were getting an exception.
+ # This test just checks for that exception to make sure it's not raised in this cas
+ def test_date_to_float_conversion
+ if EXCEL
+ assert_nothing_raised(NoMethodError) do
+ oo = Excel.new(File.join(TESTDIR,"datetime_floatconv.xls"))
+ oo.default_sheet = oo.sheets.first
+ oo.cell('a',1)
+ oo.cell('a',2)
+ end
+ end
+ end
+
end # class