Class: POI::Rows

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/poi/workbook/row.rb

Instance Method Summary collapse

Constructor Details

#initialize(worksheet) ⇒ Rows

Returns a new instance of Rows.



5
6
7
8
9
# File 'lib/poi/workbook/row.rb', line 5

def initialize(worksheet)
  @worksheet = worksheet
  @poi_worksheet = worksheet.poi_worksheet
  @rows = {}
end

Instance Method Details

#[](index) ⇒ Object



11
12
13
# File 'lib/poi/workbook/row.rb', line 11

def [](index)
  @rows[index] ||= Row.new(@poi_worksheet.get_row(index) || @poi_worksheet.create_row(index), @worksheet)
end

#eachObject



19
20
21
22
# File 'lib/poi/workbook/row.rb', line 19

def each
  it = @poi_worksheet.row_iterator
  yield Row.new(it.next, @worksheet) while it.has_next
end

#sizeObject



15
16
17
# File 'lib/poi/workbook/row.rb', line 15

def size 
  @poi_worksheet.physical_number_of_rows 
end