class RubyExcel::Column
@attr_reader [String] idx the Column
index @attr_reader [Fixnum] length the Column
length
Attributes
idx[R]
The Column
letter
index[R]
The Column
letter
Public Class Methods
new( sheet, idx )
click to toggle source
Creates a RubyExcel::Column
instance
@param [RubyExcel::Sheet] sheet the Sheet
which holds this Column
@param [String, Fixnum] idx the index of this Column
Calls superclass method
RubyExcel::Section::new
# File lib/rubyexcel/section.rb, line 337 def initialize( sheet, idx ) @idx = idx super( sheet ) end
Public Instance Methods
<<( value )
click to toggle source
Append a value to the Column
.
@param [Object] value the object to append @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.
# File lib/rubyexcel/section.rb, line 350 def <<( value ) data[ translate_address( idx == 'A' ? data.rows + 1 : data.rows ) ] = value end
length()
click to toggle source
The number of Rows in the Column
# File lib/rubyexcel/section.rb, line 358 def length data.rows end
Private Instance Methods
each_address( headers=true ) { |translate_address( row_id )| ... }
click to toggle source
# File lib/rubyexcel/section.rb, line 364 def each_address( headers=true ) return to_enum( :each_address ) unless block_given? ( headers ? 1 : sheet.header_rows + 1 ).upto( data.rows ) { |row_id| yield translate_address( row_id ) } end
translate_address( addr )
click to toggle source
# File lib/rubyexcel/section.rb, line 369 def translate_address( addr ) addr = addr.to_s unless addr.is_a?( String ) fail ArgumentError, "Invalid address : #{ addr }" if addr =~ /[^\d]/ idx + addr end