Class: RubyExcel::Column

Inherits:
Section show all
Defined in:
lib/rubyexcel/section.rb

Overview

A Column in the Sheet

Instance Attribute Summary collapse

Attributes inherited from Section

#data, #sheet

Instance Method Summary collapse

Methods inherited from Section

#cell, #delete, #each, #each_cell, #each_cell_without_headers, #each_without_headers, #empty?, #find, #inspect, #last, #last_cell, #map!, #map_without_headers!, #read, #summarise, #to_s, #write

Methods included from Address

#address_to_col_index, #address_to_indices, #col_index, #col_letter, #column_id, #expand, #indices_to_address, #multi_array?, #offset, #row_id, #to_range_address

Constructor Details

#initialize(sheet, idx) ⇒ Column

Creates a RubyExcel::Column instance

Parameters:

  • sheet (RubyExcel::Sheet)

    the Sheet which holds this Column

  • idx (String, Fixnum)

    the index of this Column



321
322
323
324
# File 'lib/rubyexcel/section.rb', line 321

def initialize( sheet, idx )
  @idx = idx
  super( sheet )
end

Instance Attribute Details

#idxObject (readonly) Also known as: index

The Column letter



308
309
310
# File 'lib/rubyexcel/section.rb', line 308

def idx
  @idx
end

#lengthObject (readonly)

The number of Rows in the Column



308
309
310
# File 'lib/rubyexcel/section.rb', line 308

def length
  @length
end

Instance Method Details

#<<(value) ⇒ Object

Note:

This only adds an extra cell if it is the first Column. This prevents a loop through Columns from extending diagonally away from the main data.

Append a value to the Column.

Parameters:

  • value (Object)

    the object to append



334
335
336
# File 'lib/rubyexcel/section.rb', line 334

def <<( value )
  data[ translate_address( idx == 'A' ? data.rows + 1 : data.rows ) ] = value
end