Class: NdrImport::File::Excel

Inherits:
Base
  • Object
show all
Includes:
OfficeFileHelper
Defined in:
lib/ndr_import/file/excel.rb

Overview

This class is an excel file handler that returns tables (worksheets). It provides a file reader method and methods to cast raw values appropriately. These methods can be overridden or aliased as required.

Instance Method Summary collapse

Methods inherited from Base

#files, #initialize

Constructor Details

This class inherits a constructor from NdrImport::File::Base

Instance Method Details

#tablesObject

Iterate through the file table by table, yielding each one in turn.



20
21
22
23
24
25
26
27
# File 'lib/ndr_import/file/excel.rb', line 20

def tables
  return enum_for(:tables) unless block_given?

  workbook = load_workbook(@filename)
  workbook.sheets.each do |sheet_name|
    yield sheet_name, excel_rows(workbook, sheet_name)
  end
end