class RubyXL::Cell
Constants
- NUMBER_REGEXP
Public Instance Methods
column()
click to toggle source
# File lib/rubyXL/objects/sheet_data.rb, line 49 def column r && r.first_col end
column=(v)
click to toggle source
# File lib/rubyXL/objects/sheet_data.rb, line 53 def column=(v) self.r = RubyXL::Reference.new(row || 0, v) end
index_in_collection()
click to toggle source
# File lib/rubyXL/objects/sheet_data.rb, line 37 def index_in_collection r.col_range.begin end
inspect()
click to toggle source
# File lib/rubyXL/objects/sheet_data.rb, line 96 def inspect str = "#<#{self.class}(#{row},#{column}): #{raw_value.inspect}" str += " =#{self.formula.expression}" if self.formula str += ", datatype=#{self.datatype.inspect}, style_index=#{self.style_index.inspect}>" return str end
is_date?()
click to toggle source
# File lib/rubyXL/objects/sheet_data.rb, line 70 def is_date? return false unless raw_value =~ NUMBER_REGEXP # Only fully numeric values can be dates num_fmt = self.number_format num_fmt && num_fmt.is_date_format? end
number_format()
click to toggle source
# File lib/rubyXL/objects/sheet_data.rb, line 66 def number_format workbook.stylesheet.get_number_format_by_id(get_cell_xf.num_fmt_id) end
raw_value()
click to toggle source
# File lib/rubyXL/objects/sheet_data.rb, line 57 def raw_value value_container && value_container.value end
raw_value=(v)
click to toggle source
# File lib/rubyXL/objects/sheet_data.rb, line 61 def raw_value=(v) self.value_container ||= RubyXL::CellValue.new value_container.value = v end
row()
click to toggle source
# File lib/rubyXL/objects/sheet_data.rb, line 41 def row r && r.first_row end
row=(v)
click to toggle source
# File lib/rubyXL/objects/sheet_data.rb, line 45 def row=(v) self.r = RubyXL::Reference.new(v, column || 0) end
value(args = {})
click to toggle source
Gets massaged value of the cell, converting datatypes to those known to Ruby (that includes stripping any special formatting from RichText
).
# File lib/rubyXL/objects/sheet_data.rb, line 78 def value(args = {}) r = self.raw_value case datatype when RubyXL::DataType::SHARED_STRING then workbook.shared_strings_container[r.to_i].to_s when RubyXL::DataType::INLINE_STRING then is.to_s when RubyXL::DataType::RAW_STRING then raw_value else if is_date? then workbook.num_to_date(r.to_f) elsif r.is_a?(String) && (r =~ NUMBER_REGEXP) then # Numeric if $1 != '' then r.to_f else r.to_i end else r end end end