From bbaeb796283afb817315633a1bbf7c492c360a40 Mon Sep 17 00:00:00 2001 From: --unset Date: Sun, 5 Apr 2009 13:54:55 -0500 Subject: [PATCH] Work around a date corner case in .xls (forced as string) There's a case where you can place a single quote in a cell to force the cell to be handled like a string. For excel, there was a test that was erroneously identifying that escaped string as a float because of a bad test to see if it's a float. This replaces that check with a better one --- Rakefile | 6 +++--- lib/roo/excel.rb | 2 +- roo.gemspec | 8 ++++---- test/datetime_floatconv.xls | Bin 0 -> 6656 bytes test/test_roo.rb | 16 +++++++++++++++- 5 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 test/datetime_floatconv.xls diff --git a/Rakefile b/Rakefile index b254900..817cc3f 100644 --- a/Rakefile +++ b/Rakefile @@ -15,8 +15,8 @@ begin s.authors = ['Thomas Preymesser'] s.files = FileList[ "{lib,test}/**/*"] s.has_rdoc = true - s.extra_rdoc_files = ["README.txt", "History.txt"] - s.rdoc_options = ["--main","README.txt"] + s.extra_rdoc_files = ["README.markdown", "History.txt"] + s.rdoc_options = ["--main","README.markdown"] s.add_dependency "spreadsheet", [">= 0.6.3.1"] s.add_dependency "rubyzip", [">= 0.9.1"] s.add_dependency "hpricot", [">= 0.5"] @@ -34,4 +34,4 @@ Rake::TestTask.new do |t| end -task :default => :test \ No newline at end of file +task :default => :test diff --git a/lib/roo/excel.rb b/lib/roo/excel.rb index 0b7e539..1e91a24 100644 --- a/lib/roo/excel.rb +++ b/lib/roo/excel.rb @@ -379,7 +379,7 @@ 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 + true if Float(object) rescue false else false end diff --git a/roo.gemspec b/roo.gemspec index 2dcf1a2..caa16e3 100644 --- a/roo.gemspec +++ b/roo.gemspec @@ -6,14 +6,14 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Thomas Preymesser"] - s.date = %q{2009-03-12} + s.date = %q{2009-04-02} 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/_ods", "test/_ods/Configurations2", "test/_ods/Configurations2/accelerator", "test/_ods/Configurations2/accelerator/current.xml", "test/_ods/Configurations2/floater", "test/_ods/Configurations2/images", "test/_ods/Configurations2/images/Bitmaps", "test/_ods/Configurations2/menubar", "test/_ods/Configurations2/popupmenu", "test/_ods/Configurations2/progressbar", "test/_ods/Configurations2/statusbar", "test/_ods/Configurations2/toolbar", "test/_ods/content.xml", "test/_ods/META-INF", "test/_ods/META-INF/manifest.xml", "test/_ods/meta.xml", "test/_ods/mimetype", "test/_ods/settings.xml", "test/_ods/style.ods", "test/_ods/styles.xml", "test/_ods/Thumbnails", "test/_ods/Thumbnails/thumbnail.png", "test/_ods_old", "test/_ods_old/Configurations2", "test/_ods_old/Configurations2/accelerator", "test/_ods_old/Configurations2/accelerator/current.xml", "test/_ods_old/Configurations2/floater", "test/_ods_old/Configurations2/images", "test/_ods_old/Configurations2/images/Bitmaps", "test/_ods_old/Configurations2/menubar", "test/_ods_old/Configurations2/popupmenu", "test/_ods_old/Configurations2/progressbar", "test/_ods_old/Configurations2/statusbar", "test/_ods_old/Configurations2/toolbar", "test/_ods_old/content.xml", "test/_ods_old/META-INF", "test/_ods_old/META-INF/manifest.xml", "test/_ods_old/meta.xml", "test/_ods_old/mimetype", "test/_ods_old/settings.xml", "test/_ods_old/style.ods", "test/_ods_old/styles.xml", "test/_ods_old/Thumbnails", "test/_ods_old/Thumbnails/thumbnail.png", "test/_xlsx", "test/_xlsx/[Content_Types].xml", "test/_xlsx/_rels", "test/_xlsx/docProps", "test/_xlsx/docProps/app.xml", "test/_xlsx/docProps/core.xml", "test/_xlsx/style.xlsx", "test/_xlsx/style.xlsx.cpgz", "test/_xlsx/xl", "test/_xlsx/xl/_rels", "test/_xlsx/xl/_rels/workbook.xml.rels", "test/_xlsx/xl/printerSettings", "test/_xlsx/xl/printerSettings/printerSettings1.bin", "test/_xlsx/xl/sharedStrings.xml", "test/_xlsx/xl/styles.xml", "test/_xlsx/xl/theme", "test/_xlsx/xl/theme/theme1.xml", "test/_xlsx/xl/workbook.xml", "test/_xlsx/xl/worksheets", "test/_xlsx/xl/worksheets/_rels", "test/_xlsx/xl/worksheets/_rels/sheet1.xml.rels", "test/_xlsx/xl/worksheets/sheet1.xml", "test/_xlsx/xl/worksheets/sheet2.xml", "test/_xlsx/xl/worksheets/sheet3.xml", "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.extra_rdoc_files = ["README.markdown", "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.markdown", "History.txt"] s.has_rdoc = true s.homepage = %q{http://roo.rubyforge.org} - s.rdoc_options = ["--main", "README.txt", "--inline-source", "--charset=UTF-8"] + s.rdoc_options = ["--main", "README.markdown", "--inline-source", "--charset=UTF-8"] s.require_paths = ["lib"] s.rubyforge_project = %q{roo} s.rubygems_version = %q{1.3.1} diff --git a/test/datetime_floatconv.xls b/test/datetime_floatconv.xls new file mode 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