Module: SimpleExcelImport::ImportFile

Defined in:
lib/simple-excel-import.rb

Defined Under Namespace

Classes: FormatError

Class Method Summary collapse

Class Method Details

.open_spreadsheet(file) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/simple-excel-import.rb', line 73

def self.open_spreadsheet(file)
  extname = File.extname file

  case extname
    when '.sxc' 
      Roo::Openoffice.new(file.path, nil, :ignore)
    when '.xls' 
      Roo::Excel.new(file.path, nil, :ignore)
    when '.xlsx' 
      Roo::Excelx.new(file.path, nil, :ignore)
    else 
      raise FormatError.new "Unsupported file format #{extname}"
  end
end