4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/roo/spreadsheet.rb', line 4
def open(file, options = {})
file = File === file ? file.path : file
extension =
if options[:extension]
options[:file_warning] = :ignore
".#{options[:extension]}"
else
File.extname(file)
end
case extension.downcase
when '.xls'
Roo::Excel.new(file, options)
when '.xlsx'
Roo::Excelx.new(file, options)
when '.ods'
Roo::OpenOffice.new(file, options)
when '.xml'
Roo::Excel2003XML.new(file, options)
when ''
Roo::Google.new(file, options)
when '.csv'
Roo::CSV.new(file, options)
else
raise ArgumentError, "Don't know how to open file #{file}"
end
end
|