Class: RubyFromExcel::Rows

Inherits:
ExcelRangeCommon show all
Defined in:
lib/formulae/run/excel_range.rb

Instance Attribute Summary collapse

Attributes inherited from ExcelRangeCommon

#sheet

Instance Method Summary collapse

Methods inherited from ExcelRangeCommon

#each

Constructor Details

#initialize(sheet, start_row_number, end_row_number) ⇒ Rows

Returns a new instance of Rows.


215
216
217
218
219
# File 'lib/formulae/run/excel_range.rb', line 215

def initialize(sheet,start_row_number,end_row_number)
  self.sheet = sheet
  self.start_row_number = start_row_number.to_i
  self.end_row_number = end_row_number.to_i
end

Instance Attribute Details

#end_row_numberObject

Returns the value of attribute end_row_number


213
214
215
# File 'lib/formulae/run/excel_range.rb', line 213

def end_row_number
  @end_row_number
end

#start_row_numberObject

Returns the value of attribute start_row_number


213
214
215
# File 'lib/formulae/run/excel_range.rb', line 213

def start_row_number
  @start_row_number
end

Instance Method Details

#array_formula_index(row_index, column_index) ⇒ Object


221
222
223
224
225
226
# File 'lib/formulae/run/excel_range.rb', line 221

def array_formula_index(row_index,column_index)
  row_index = 0 if single_row?
  reference = Reference.new(Reference.ruby_for(column_index+1,row_index+1))
  return :na unless include?(reference)
  reference.to_ruby
end

#to_enumObject


228
229
230
231
232
233
234
235
236
# File 'lib/formulae/run/excel_range.rb', line 228

def to_enum
  Enumerator.new do |yielder|
    (start_row_number..end_row_number).each do |row|
      (1..maximum_column_number_in_row_number(row)).each do |column_number|
        yielder << value_at(Reference.ruby_for(column_number,row))
      end
    end
  end
end