Skip to content

Commit

Permalink
first pass at excel2003 xml spport
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugh McGowan committed Dec 21, 2009
1 parent 9ad018c commit 4750e5b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
3 changes: 3 additions & 0 deletions lib/roo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ def open(file)
Excelx.new(file)
when '.ods'
Openoffice.new(file)
when '.xml'
Excel2003.new(file)
when ''
Google.new(file)
else
Expand All @@ -26,4 +28,5 @@ def open(file)
require 'roo/excel'
require 'roo/excelx'
require 'roo/google'
require 'roo/excel2003'
require 'roo/roo_rails_helper'
3 changes: 2 additions & 1 deletion lib/roo/generic_spreadsheet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,10 @@ def file_type_check(filename, ext, name)
'.ods' => 'Openoffice.new',
'.xls' => 'Excel.new',
'.xlsx' => 'Excelx.new',
'.xml' => 'Excel2003.new'
}
case ext
when '.ods', '.xls', '.xlsx'
when '.ods', '.xls', '.xlsx', '.xml'
correct_class = "use #{new_expression[ext]} to handle #{ext} spreadsheet files"
else
raise "unknown file type: #{ext}"
Expand Down
4 changes: 3 additions & 1 deletion roo.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Gem::Specification.new do |s|

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Hugh McGowan", "Thomas Preymesser"]
s.date = %q{2009-08-31}
s.date = %q{2009-12-21}
s.description = %q{roo can access the contents of OpenOffice-, Excel- or Google-Spreadsheets}
s.email = %q{hugh_mcgowan@yahoo.com}
s.extra_rdoc_files = [
Expand All @@ -19,6 +19,7 @@ Gem::Specification.new do |s|
s.files = [
"lib/roo.rb",
"lib/roo/excel.rb",
"lib/roo/excel2003.rb",
"lib/roo/excelx.rb",
"lib/roo/generic_spreadsheet.rb",
"lib/roo/google.rb",
Expand Down Expand Up @@ -51,6 +52,7 @@ Gem::Specification.new do |s|
"test/datetime_floatconv.xls",
"test/emptysheets.ods",
"test/emptysheets.xls",
"test/excel2003.xml",
"test/false_encoding.xls",
"test/formula.ods",
"test/formula.xls",
Expand Down
14 changes: 12 additions & 2 deletions test/test_roo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ def minutes

class TestRoo < Test::Unit::TestCase

OPENOFFICE = true # do Openoffice-Spreadsheet Tests?
OPENOFFICE = false # do Openoffice-Spreadsheet Tests?
EXCEL = true # do Excel Tests?
GOOGLE = false # do Google-Spreadsheet Tests?
EXCELX = true # do Excel-X Tests? (.xlsx-files)
EXCELX = false # do Excel-X Tests? (.xlsx-files)

ONLINE = true
LONG_RUN = false
Expand All @@ -155,6 +155,7 @@ def with_each_spreadsheet(options)
yield Roo::Spreadsheet.open(File.join(TESTDIR, options[:name] + '.xls')) if EXCEL && options[:format].include?(:excel)
yield Roo::Spreadsheet.open(File.join(TESTDIR, options[:name] + '.xlsx')) if EXCELX && options[:format].include?(:excelx)
yield Roo::Spreadsheet.open(File.join(TESTDIR, options[:name] + '.ods')) if OPENOFFICE && options[:format].include?(:openoffice)
yield Roo::Spreadsheet.open(File.join(TESTDIR, options[:name] + '.xml')) if EXCEL && options[:format].include?(:excel2003)
yield Roo::Spreadsheet.open(key_of(options[:name]) || options[:name]) if GOOGLE && options[:format].include?(:google)
end

Expand Down Expand Up @@ -1800,6 +1801,15 @@ def test_bad_excel_date
}
end
end

def test_foo
with_each_spreadsheet(:name=>'excel2003', :format=>:excel2003) do |oo|
oo.default_sheet = 'SiteData'
puts oo.cell(1,1)
puts oo.cell(1,2)
end
end


def test_public_google_doc
with_public_google_spreadsheet do
Expand Down

0 comments on commit 4750e5b

Please sign in to comment.