lib/spree_importer/importer.rb
# Receives a file instance and then returns a Roo object acording the file extension
#
# @params:
#   file     File   -  a file intance with data to load
#
# Returns a Roo instance acording the file extension.
Receives a file instance and then returns a Roo object acording the file extension
Receives a file instance and then returns a Roo object acording the file extension
def open_spreadsheet
        case File.extname(@filename)
          when '.csv'  then @spreadsheet = Roo::CSV.new(@filepath)
          when '.xls'  then @spreadsheet = Roo::Excel.new(@filepath, nil, :ignore)
          when '.xlsx' then @spreadsheet = Roo::Excelx.new(@filepath, nil, :ignore)
          else raise "#{__FILE__}:#{__LINE__} #{I18n.t(:unknown_file_type, scope: [:spree, :spree_importer, :messages], filename: @filename)}"
        end
        @spreadsheet.default_sheet = @spreadsheet.sheets.first
      end
def open_spreadsheet case File . extname ( @filename ) when '.csv' then @spreadsheet = Roo :: CSV . new ( @filepath ) when '.xls' then @spreadsheet = Roo :: Excel . new ( @filepath , nil , :ignore ) when '.xlsx' then @spreadsheet = Roo :: Excelx . new ( @filepath , nil , :ignore ) else raise "#{__FILE__}:#{__LINE__} #{I18n.t(:unknown_file_type, scope: [:spree, :spree_importer, :messages], filename: @filename)}" end @spreadsheet . default_sheet = @spreadsheet . sheets . first end
Receives a file instance and then returns a Roo object acording the file extension
Receives a file instance and then returns a Roo object acording the file extension
params:
file File - a file intance with data to load Returns a Roo instance acording the file extension.
file File - a file intance with data to load Returns a Roo instance acording the file extension .