class ExcelUtils::Workbooks::Excel
Attributes
filename[R]
normalize_column_names[R]
spreadsheet[R]
Public Class Methods
new(filename, normalize_column_names: false, extension: nil)
click to toggle source
# File lib/excel_utils/workbooks/excel.rb, line 7 def initialize(filename, normalize_column_names: false, extension: nil) @filename = filename @normalize_column_names = normalize_column_names @spreadsheet = Roo::Spreadsheet.open filename, extension: extension end
Public Instance Methods
[](sheet_name)
click to toggle source
# File lib/excel_utils/workbooks/excel.rb, line 21 def [](sheet_name) sheets.detect { |sheet| sheet.name == sheet_name } end
sheets()
click to toggle source
# File lib/excel_utils/workbooks/excel.rb, line 13 def sheets @sheets ||= spreadsheet.sheets.map do |name| sheet_class.new name: name, normalize_column_names: normalize_column_names, spreadsheet: spreadsheet end end
to_h()
click to toggle source
# File lib/excel_utils/workbooks/excel.rb, line 25 def to_h sheets.each_with_object({}) do |sheet, hash| hash[sheet.name] = sheet.to_a end end
Private Instance Methods
sheet_class()
click to toggle source
# File lib/excel_utils/workbooks/excel.rb, line 35 def sheet_class @sheet_class ||= spreadsheet.respond_to?(:each_row_streaming) ? Sheets::ExcelStream : Sheets::Excel end