Class: RubyExcel::Cell

Inherits:
Element show all
Defined in:
lib/rubyexcel/element.rb

Overview

A single Cell

Instance Attribute Summary

Attributes inherited from Element

#address, #column, #data, #row, #sheet

Instance Method Summary collapse

Methods inherited from Element

#delete, #each, #each_cell, #empty?, #first_cell, #inspect, #last_cell, #map!

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, addr) ⇒ Cell

Returns a new instance of Cell.



121
122
123
124
# File 'lib/rubyexcel/element.rb', line 121

def initialize( sheet, addr )
  fail ArgumentError, "Invalid Cell address: #{ addr }" unless addr =~ /\A[A-Z]{1,3}\d+\z/
  super
end

Instance Method Details

#to_sObject

The data at address as a String



150
151
152
# File 'lib/rubyexcel/element.rb', line 150

def to_s
  val.to_s
end

#valueObject

Return the value at this Cell’s address

Returns:

  • (Object)

    the Object within the data, referenced by the address



132
133
134
# File 'lib/rubyexcel/element.rb', line 132

def value
  data[ address ]
end

#value=(val) ⇒ Object

Set the value at this Cell’s address

Parameters:

  • val (Object)

    the Object to write into the data



142
143
144
# File 'lib/rubyexcel/element.rb', line 142

def value=( val )
  data[ address ] = val
end