Class: RubyFromExcel::Columns

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_column, end_column) ⇒ Columns

Returns a new instance of Columns.


171
172
173
174
175
# File 'lib/formulae/run/excel_range.rb', line 171

def initialize(sheet,start_column,end_column)
  self.sheet = sheet
  self.start_column_number = Reference.column_to_integer(start_column)
  self.end_column_number = Reference.column_to_integer(end_column)
end

Instance Attribute Details

#end_column_numberObject

Returns the value of attribute end_column_number


169
170
171
# File 'lib/formulae/run/excel_range.rb', line 169

def end_column_number
  @end_column_number
end

#start_column_numberObject

Returns the value of attribute start_column_number


169
170
171
# File 'lib/formulae/run/excel_range.rb', line 169

def start_column_number
  @start_column_number
end

Instance Method Details

#array_formula_index(row_index, column_index) ⇒ Object


177
178
179
180
181
182
# File 'lib/formulae/run/excel_range.rb', line 177

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

#to_enumObject


184
185
186
187
188
189
190
191
192
# File 'lib/formulae/run/excel_range.rb', line 184

def to_enum
  Enumerator.new do |yielder|
    (start_column_number..end_column_number).each do |column_number|
      (1..maximum_row_in_column_number(column_number)).each do |row|
        yielder << value_at(Reference.ruby_for(column_number,row))
      end
    end
  end
end