class RubyXL::Cell

www.schemacentral.com/sc/ooxml/e-ssml_c-2.html

Public Instance Methods

column() click to toggle source
# File lib/rubyXL/objects/sheet_data.rb, line 46
def column
  r && r.first_col
end
column=(v) click to toggle source
# File lib/rubyXL/objects/sheet_data.rb, line 50
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 34
def index_in_collection
  r.col_range.begin
end
is_date?() click to toggle source
# File lib/rubyXL/objects/sheet_data.rb, line 67
def is_date?
  return false unless raw_value =~ /\A\d+(?:\.\d+)?\Z/ # 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 63
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 54
def raw_value
  value_container && value_container.value
end
raw_value=(v) click to toggle source
# File lib/rubyXL/objects/sheet_data.rb, line 58
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 38
def row
  r && r.first_row
end
row=(v) click to toggle source
# File lib/rubyXL/objects/sheet_data.rb, line 42
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 75
def value(args = {})
  return raw_value if args[:raw]
  case datatype
  when RubyXL::DataType::SHARED_STRING then
    workbook.shared_strings_container[raw_value.to_i].to_s
  else
    if is_date? then workbook.num_to_date(raw_value.to_f)
    elsif raw_value.is_a?(String) && (raw_value =~ /\A-?\d+(\.\d+(?:e[+-]\d+)?)?\Z/i) # Numeric
      if $1 then raw_value.to_f
      else raw_value.to_i
      end
    else raw_value
    end
  end
end