Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

update roo to use ruby-spreadsheet from parseexcel

  • Loading branch information...
commit 71a56aa5a1ba00c9ca395d81c535323c7ca93fd5 1 parent 2a3d371
@hmcgowan authored
View
1  .gitignore
@@ -0,0 +1 @@
+pkg/
View
2  Rakefile
@@ -17,7 +17,7 @@ begin
s.has_rdoc = true
s.extra_rdoc_files = ["README.txt", "History.txt"]
s.rdoc_options = ["--main","README.txt"]
- s.add_dependency "parseexcel", [">= 0.5.3"]
+ s.add_dependency "spreadsheet", [">= 0.6.3.1"]
s.add_dependency "rubyzip", [">= 0.9.1"]
s.add_dependency "hpricot", [">= 0.5"]
s.add_dependency "GData", [">= 0.0.3"]
View
4 VERSION.yml
@@ -0,0 +1,4 @@
+---
+:patch: 4
+:major: 1
+:minor: 2
View
178 lib/roo/excel.rb
@@ -1,6 +1,6 @@
require 'rubygems'
-gem 'parseexcel', '>= 0.5.3'
-require 'parseexcel'
+gem 'spreadsheet', '>= 0.6.3.1'
+require 'spreadsheet'
CHARGUESS = false
require 'charguess' if CHARGUESS
@@ -37,7 +37,7 @@ def initialize(filename, packed = nil, file_warning = :error)
unless File.file?(@filename)
raise IOError, "file #{@filename} does not exist"
end
- @workbook = Spreadsheet::ParseExcel.parse(filename)
+ @workbook = Spreadsheet.open(filename)
@default_sheet = nil
# no need to set default_sheet if there is only one sheet in the document
if self.sheets.size == 1
@@ -63,19 +63,18 @@ def initialize(filename, packed = nil, file_warning = :error)
# returns an array of sheet names in the spreadsheet
def sheets
result = []
- #0.upto(@workbook.worksheets.size - 1) do |i| # spreadsheet
- 0.upto(@workbook.sheet_count - 1) do |i| # parseexcel
+ @workbook.worksheets.each do |worksheet|
# TODO: is there a better way to do conversion?
if CHARGUESS
- encoding = CharGuess::guess(@workbook.worksheet(i).name)
+ encoding = CharGuess::guess(worksheet.name)
encoding = 'unicode' unless encoding
result << Iconv.new('utf-8',encoding).iconv(
- @workbook.worksheet(i).name
+ worksheet.name
)
else
- result << platform_specific_iconv(@workbook.worksheet(i).name)
+ result << platform_specific_iconv(worksheet.name)
end
end
return result
@@ -181,17 +180,23 @@ def cell_font(row, col, sheet=nil)
# true if the cell style is bold
def bold?(*args)
- cell_font(*args)[:bold]
+ #From ruby-spreadsheet doc: 100 <= weight <= 1000, bold => 700, normal => 400
+ case cell_font(*args).weight
+ when 700
+ true
+ else
+ false
+ end
end
# true if the cell style is italic
def italic?(*args)
- cell_font(*args)[:italic]
+ cell_font(*args).italic
end
# true if the cell style is underline
def underline?(*args)
- cell_font(*args)[:underline]
+ cell_font(*args).underline != :none
end
# shows the internal representation of all cells
@@ -243,14 +248,15 @@ def get_firsts_lasts(sheet=nil)
# converts name of a sheet to index (0,1,2,..)
def sheet_no(name)
return name-1 if name.kind_of?(Fixnum)
- 0.upto(@workbook.sheet_count - 1) do |i|
- #0.upto(@workbook.worksheets.size - 1) do |i|
+ i = 0
+ @workbook.worksheets.each do |worksheet|
# TODO: is there a better way to do conversion?
return i if name == platform_specific_iconv(
- @workbook.worksheet(i).name)
+ worksheet.name)
#Iconv.new('utf-8','unicode').iconv(
# @workbook.worksheet(i).name
# )
+ i += 1
end
raise StandardError, "sheet '#{name}' not found"
end
@@ -316,9 +322,9 @@ def remove_every_second_null(str)
end
# helper function to set the internal representation of cells
- def set_cell_values(sheet,x,y,i,v,vt,formula,tr,str_v, font)
+ def set_cell_values(sheet,row,col,i,v,vt,formula,tr,font)
#key = "#{y},#{x+i}"
- key = [y,x+i]
+ key = [row,col+i]
@cell_type[sheet] = {} unless @cell_type[sheet]
@cell_type[sheet][key] = vt
@formula[sheet] = {} unless @formula[sheet]
@@ -331,7 +337,7 @@ def set_cell_values(sheet,x,y,i,v,vt,formula,tr,str_v, font)
when :float
@cell[sheet][key] = v.to_f
when :string
- @cell[sheet][key] = str_v
+ @cell[sheet][key] = v
when :date
@cell[sheet][key] = v
when :datetime
@@ -356,67 +362,89 @@ def read_cells(sheet=nil)
end
worksheet = @workbook.worksheet(sheet_no(sheet))
- skip = 0
- x =1
- y=1
- i=0
- worksheet.each(skip) { |row_par|
- if row_par
- x =1
- row_par.each do # |void|
- cell = row_par.at(x-1)
- if cell
- case cell.type
- when :numeric
- vt = :float
- v = cell.to_f
- when :text
- vt = :string
- if cell.to_s.downcase == 'true'
- str_v = cell.to_s
- else
- str_v = cell.to_s('utf-8')
- end
- when :date
- if cell.to_s.to_f < 1.0
- vt = :time
- f = cell.to_s.to_f*24.0*60.0*60.0
- secs = f.round
- h = (secs / 3600.0).floor
- secs = secs - 3600*h
- m = (secs / 60.0).floor
- secs = secs - 60*m
- s = secs
- v = h*3600+m*60+s
- else
- if cell.datetime.hour != 0 or
- cell.datetime.min != 0 or
- cell.datetime.sec != 0 or
- cell.datetime.msec != 0
- vt = :datetime
- v = cell.datetime
- else
- vt = :date
- v = cell.date
- v = sprintf("%04d-%02d-%02d",v.year,v.month,v.day)
- end
- end
- else
- vt = cell.type.to_s.downcase.to_sym
- v = nil
- end # case
- formula = tr = nil #TODO:???
- set_cell_values(sheet,x,y,i,v,vt,formula,tr,str_v, cell.font)
- end # if cell
-
- x += 1
+ row_index=1
+ worksheet.each(0) do |row|
+ (0..row.size).each do |cell_index|
+ cell = row.at(cell_index)
+ next if cell.nil? #skip empty cells
+ next if cell.class == Spreadsheet::Formula
+ if date_or_time?(row, cell_index)
+ vt, v = read_cell_date_or_time(row, cell_index)
+ else
+ vt, v = read_cell(row, cell_index)
end
- end
- y += 1
- }
+ formula = tr = nil #TODO:???
+ col_index = cell_index + 1
+ font = row.format(cell_index).font
+#puts [row_index, col_index].inspect
+#puts vt, v
+ set_cell_values(sheet,row_index,col_index,0,v,vt,formula,tr,font)
+ end #row
+ row_index += 1
+ end # worksheets
@cells_read[sheet] = true
end
-
+
+ # Test the cell to see if it's a valid date/time.
+ def date_or_time?(row, idx)
+ format = row.format(idx)
+ if format.date_or_time?
+ cell = row.at(idx)
+ cell.to_s.to_f > 0 ? true : false # cell value must be numeric
+ else
+ false
+ end
+ end
+ private :date_or_time?
+
+ def read_cell_date_or_time(row, idx)
+ cell = row.at(idx).to_s.to_f
+ if cell < 1.0
+ value_type = :time
+ f = cell*24.0*60.0*60.0
+ secs = f.round
+ h = (secs / 3600.0).floor
+ secs = secs - 3600*h
+ m = (secs / 60.0).floor
+ secs = secs - 60*m
+ s = secs
+ value = h*3600+m*60+s
+ else
+ datetime = row.datetime(idx)
+ if datetime.hour != 0 or
+ datetime.min != 0 or
+ datetime.sec != 0
+ value_type = :datetime
+ value = datetime
+ else
+ value_type = :date
+ value = row.date(idx)
+ value = sprintf("%04d-%02d-%02d",value.year,value.month,value.day)
+ end
+ end
+ return value_type, value
+ end
+ private :read_cell_date_or_time
+
+ # Read the cell and based on the class,
+ # return the value and value types for Roo
+ def read_cell(row, idx)
+ cell = row.at(idx)
+ case cell
+ when Float, Integer, Fixnum, Bignum
+ value_type = :float
+ value = cell.to_f
+ when String, TrueClass, FalseClass
+ value_type = :string
+ value = cell.to_s
+ else
+ value_type = cell.class.to_s.downcase.to_sym
+ value = nil
+ end # case
+ return value_type, value
+ end
+ private :read_cell
+
#TODO: testing only
# def inject_null_characters(str)
# if str.class != String
View
44 roo.gemspec
@@ -0,0 +1,44 @@
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{roo}
+ s.version = "1.2.4"
+ s.platform = %q{universal-darwin-9}
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Thomas Preymesser"]
+ s.date = %q{2009-02-21}
+ s.description = %q{roo can access the contents of OpenOffice-, Excel- or Google-Spreadsheets}
+ s.email = %q{thopre@gmail.com}
+ s.extra_rdoc_files = ["README.txt", "History.txt"]
+ s.files = ["lib/roo", "lib/roo/excel.rb", "lib/roo/excelx.rb", "lib/roo/generic_spreadsheet.rb", "lib/roo/google.rb", "lib/roo/openoffice.rb", "lib/roo/roo_rails_helper.rb", "lib/roo/version.rb", "lib/roo.rb", "test/bbu.ods", "test/bbu.xls", "test/bbu.xlsx", "test/Bibelbund.csv", "test/Bibelbund.ods", "test/Bibelbund.xls", "test/Bibelbund.xlsx", "test/Bibelbund1.ods", "test/bode-v1.ods.zip", "test/bode-v1.xls.zip", "test/boolean.ods", "test/boolean.xls", "test/boolean.xlsx", "test/borders.ods", "test/borders.xls", "test/borders.xlsx", "test/bug-row-column-fixnum-float.xls", "test/datetime.ods", "test/datetime.xls", "test/datetime.xlsx", "test/emptysheets.ods", "test/emptysheets.xls", "test/false_encoding.xls", "test/formula.ods", "test/formula.xls", "test/formula.xlsx", "test/html-escape.ods", "test/no_spreadsheet_file.txt", "test/numbers1.csv", "test/numbers1.ods", "test/numbers1.xls", "test/numbers1.xlsx", "test/numbers1_excel.csv", "test/only_one_sheet.ods", "test/only_one_sheet.xls", "test/only_one_sheet.xlsx", "test/ric.ods", "test/simple_spreadsheet.ods", "test/simple_spreadsheet.xls", "test/simple_spreadsheet.xlsx", "test/simple_spreadsheet_from_italo.ods", "test/simple_spreadsheet_from_italo.xls", "test/style.ods", "test/style.xls", "test/style.xlsx", "test/test_helper.rb", "test/test_roo.rb", "test/time-test.csv", "test/time-test.ods", "test/time-test.xls", "test/time-test.xlsx", "README.txt", "History.txt"]
+ s.has_rdoc = true
+ s.homepage = %q{http://raa.ruby-lang.org/project/parseexcel/}
+ s.rdoc_options = ["--main", "README.txt", "--inline-source", "--charset=UTF-8"]
+ s.require_paths = ["lib"]
+ s.rubyforge_project = %q{roo}
+ s.rubygems_version = %q{1.3.1}
+ s.summary = %q{roo}
+
+ if s.respond_to? :specification_version then
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+ s.specification_version = 2
+
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
+ s.add_runtime_dependency(%q<spreadsheet>, [">= 0.6.3.1"])
+ s.add_runtime_dependency(%q<rubyzip>, [">= 0.9.1"])
+ s.add_runtime_dependency(%q<hpricot>, [">= 0.5"])
+ s.add_runtime_dependency(%q<GData>, [">= 0.0.3"])
+ else
+ s.add_dependency(%q<spreadsheet>, [">= 0.6.3.1"])
+ s.add_dependency(%q<rubyzip>, [">= 0.9.1"])
+ s.add_dependency(%q<hpricot>, [">= 0.5"])
+ s.add_dependency(%q<GData>, [">= 0.0.3"])
+ end
+ else
+ s.add_dependency(%q<spreadsheet>, [">= 0.6.3.1"])
+ s.add_dependency(%q<rubyzip>, [">= 0.9.1"])
+ s.add_dependency(%q<hpricot>, [">= 0.5"])
+ s.add_dependency(%q<GData>, [">= 0.0.3"])
+ end
+end
View
75 test/test_roo.rb
@@ -1864,8 +1864,8 @@ def split_coord(s)
# 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)
@@ -1940,6 +1940,7 @@ def test_excel_open_from_uri_and_zipped
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
@@ -3044,7 +3045,7 @@ def test_column_openoffice
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')
@@ -3057,7 +3058,7 @@ 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')
@@ -3069,7 +3070,7 @@ 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')
@@ -3094,7 +3095,7 @@ def test_column_huge_document_openoffice
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
@@ -3109,7 +3110,7 @@ def test_column_huge_document_excel
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
@@ -3124,7 +3125,7 @@ def test_column_huge_document_excelx
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
@@ -3233,7 +3234,7 @@ def test_simple_spreadsheet_find_by_condition_google
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|
@@ -3252,7 +3253,7 @@ def DONT_test_false_encoding
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
@@ -3272,7 +3273,7 @@ def test_bug_false_borders_with_formulas
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)
@@ -3298,7 +3299,7 @@ def test_fe
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)
@@ -3491,7 +3492,7 @@ def test_set_value_for_non_existing_sheet_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
@@ -3516,7 +3517,7 @@ def test_bug_bbu_openoffice
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
@@ -3542,7 +3543,7 @@ def test_bug_bbu_excel
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
@@ -3756,7 +3757,7 @@ def test_no_remaining_tmp_files_openoffice
def test_no_remaining_tmp_files_excel
if EXCEL
- assert_raise(OLE::UnknownFormatError) {
+ 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(TESTDIR,"no_spreadsheet_file.txt"),
@@ -3842,28 +3843,28 @@ def do_test_xml(oo)
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
@@ -3879,7 +3880,7 @@ def SKIP_test_invalid_iconv_from_ms
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)
@@ -3900,7 +3901,7 @@ def test_bug_c2
'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
@@ -3919,7 +3920,7 @@ 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
@@ -3937,7 +3938,7 @@ def test_bug_c2_parseexcel
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
@@ -3968,7 +3969,7 @@ def test_bug_c2_excelx
'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)
@@ -3981,7 +3982,7 @@ def test_bug_c2_excelx
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
@@ -4107,11 +4108,11 @@ def test_file_warning_warning
end
if EXCEL
assert_nothing_raised(TypeError) {
- assert_raises(OLE::UnknownFormatError) {
+ assert_raises(Ole::Storage::FormatError) {
oo = Excel.new(File.join(TESTDIR,"numbers1.ods"),false, :warning) }
}
assert_nothing_raised(TypeError) {
- assert_raises(OLE::UnknownFormatError) {
+ assert_raises(Ole::Storage::FormatError) {
oo = Excel.new(File.join(TESTDIR,"numbers1.xlsx"),false, :warning) }
}
assert_equal [], Dir.glob("oo_*")
@@ -4143,11 +4144,11 @@ def test_file_warning_ignore
end
if EXCEL
assert_nothing_raised(TypeError) {
- assert_raises(OLE::UnknownFormatError) {
+ 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(TESTDIR,"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
@@ -4335,7 +4336,7 @@ 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
@@ -4343,7 +4344,7 @@ def test_possible_bug_snowboard_borders
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
@@ -4374,13 +4375,13 @@ def test_possible_bug_snowboard_cells
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
@@ -4597,7 +4598,7 @@ def test_possible_bug_2008_09_13
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
@@ -4850,8 +4851,8 @@ def test_cell_excel_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)
+ 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"))
Please sign in to comment.
Something went wrong with that request. Please try again.