class RubyXL::Cell
Constants
- NUMBER_REGEXP
Attributes
Public Instance Methods
Source
# File lib/rubyXL/objects/sheet_data.rb, line 64 def column=(v) self.r = RubyXL::Reference.new(row || 0, v) end
Source
# File lib/rubyXL/objects/sheet_data.rb, line 85 def get_cell_border workbook.stylesheet.borders[get_cell_xf.border_id] end
Source
# File lib/rubyXL/objects/sheet_data.rb, line 81 def get_cell_font workbook.stylesheet.fonts[get_cell_xf.font_id] end
Source
# File lib/rubyXL/objects/sheet_data.rb, line 77 def get_cell_xf workbook.stylesheet.cell_xfs[self.style_index || 0] end
Source
# File lib/rubyXL/objects/sheet_data.rb, line 48 def index_in_collection r.col_range.begin end
Source
# File lib/rubyXL/objects/sheet_data.rb, line 126 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
Source
# File lib/rubyXL/objects/sheet_data.rb, line 93 def is_date? return false unless # Only fully numeric values can be dates case raw_value when Numeric then true when String then raw_value =~ NUMBER_REGEXP else false end self.number_format&.is_date_format? end
Source
# File lib/rubyXL/objects/sheet_data.rb, line 89 def number_format workbook.stylesheet.get_number_format_by_id(get_cell_xf.num_fmt_id) end
Source
# File lib/rubyXL/objects/sheet_data.rb, line 68 def raw_value value_container&.value end
Source
# File lib/rubyXL/objects/sheet_data.rb, line 72 def raw_value=(v) self.value_container ||= RubyXL::CellValue.new value_container.value = v end
Source
# File lib/rubyXL/objects/sheet_data.rb, line 56 def row=(v) self.r = RubyXL::Reference.new(v, column || 0) end
Source
# File lib/rubyXL/objects/sheet_data.rb, line 106 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 when RubyXL::DataType::DATE then raw_value && DateTime.parse(raw_value) else if is then is.to_s elsif is_date? then workbook.num_to_date(r.to_f) elsif r.is_a?(String) && (r =~ NUMBER_REGEXP) then # Numeric if Regexp.last_match(1) != '' then r.to_f else r.to_i end else r end end end
Gets massaged value of the cell, converting datatypes to those known to Ruby (that includes stripping any special formatting from RichText).