Class: Decidim::Admin::Import::Readers::XLSX

Inherits:
Base
  • Object
show all
Defined in:
decidim-admin/lib/decidim/admin/import/readers/xlsx.rb

Overview

Imports any exported XLSX file to local objects. It transforms the import data using the creator into the final target objects.

Constant Summary collapse

MIME_TYPE =
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Decidim::Admin::Import::Readers::Base

Instance Method Details

#read_rowsObject


14
15
16
17
18
19
20
# File 'decidim-admin/lib/decidim/admin/import/readers/xlsx.rb', line 14

def read_rows
  workbook = RubyXL::Parser.parse(file)
  sheet = workbook.worksheets[0]
  sheet.each_with_index do |row, index|
    yield row.cells.map(&:value), index
  end
end