Class: RubyExcel::Row
Overview
A Row in the Sheet
Instance Attribute Summary collapse
-
#idx ⇒ Fixnum
readonly
the Row index.
-
#length ⇒ Fixnum
readonly
the Row length.
Attributes inherited from Section
Instance Method Summary collapse
-
#cell_by_header(header) ⇒ RubyExcel::Element
(also: #cell_h)
Access a cell by its header.
-
#getref(header) ⇒ String
Find the Address of a header.
-
#initialize(sheet, idx) ⇒ Row
constructor
Creates a RubyExcel::Row instance.
-
#value_by_header(header) ⇒ Object
(also: #val)
Find a value in this Row by its header.
Methods inherited from Section
#<<, #cell, #delete, #each, #each_cell, #each_cell_without_headers, #each_without_headers, #empty?, #find, #inspect, #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) ⇒ Row
Creates a RubyExcel::Row instance
229 230 231 232 |
# File 'lib/rubyexcel/section.rb', line 229 def initialize( sheet, idx ) @idx = idx.to_i super( sheet ) end |
Instance Attribute Details
#idx ⇒ Fixnum (readonly)
the Row index
218 219 220 |
# File 'lib/rubyexcel/section.rb', line 218 def idx @idx end |
#length ⇒ Fixnum (readonly)
the Row length
218 219 220 |
# File 'lib/rubyexcel/section.rb', line 218 def length @length end |
Instance Method Details
#cell_by_header(header) ⇒ RubyExcel::Element Also known as: cell_h
Access a cell by its header
241 242 243 |
# File 'lib/rubyexcel/section.rb', line 241 def cell_by_header( header ) cell( getref( header ) ) end |
#getref(header) ⇒ String
Find the Address of a header
253 254 255 256 257 258 259 |
# File 'lib/rubyexcel/section.rb', line 253 def getref( header ) sheet.header_rows.times do |t| res = sheet.row( t + 1 ).find &/^#{header}$/ return column_id( res ) if res end fail ArgumentError, 'Invalid header: ' + header.to_s end |
#value_by_header(header) ⇒ Object Also known as: val
Find a value in this Row by its header
272 273 274 |
# File 'lib/rubyexcel/section.rb', line 272 def value_by_header( header ) self[ getref( header ) ] end |