Class: RubyXL::Cell
Overview
Instance Attribute Summary
Attributes included from LegacyCell
#formula, #worksheet
Instance Method Summary
collapse
#change_border, #change_contents, #change_horizontal_alignment, #change_text_wrap, #change_vertical_alignment, #fill_color, #font_color, #font_name, #font_size, #get_border, #horizontal_alignment, #is_bolded, #is_italicized, #is_struckthrough, #is_underlined, #set_number_format, #text_wrap, #vertical_alignment
Methods included from LegacyCell
#change_fill, #change_font_bold, #change_font_color, #change_font_italics, #change_font_name, #change_font_size, #change_font_strikethrough, #change_font_underline, #font_switch, #workbook
#==, #before_write_xml, included, #initialize, #write_xml
Instance Method Details
#column ⇒ Object
47
48
49
|
# File 'lib/rubyXL/objects/sheet_data.rb', line 47
def column
r && r.first_col
end
|
#column=(v) ⇒ Object
51
52
53
|
# File 'lib/rubyXL/objects/sheet_data.rb', line 51
def column=(v)
self.r = RubyXL::Reference.new(row || 0, v)
end
|
#index_in_collection ⇒ Object
35
36
37
|
# File 'lib/rubyXL/objects/sheet_data.rb', line 35
def index_in_collection
r.col_range.begin
end
|
#inspect ⇒ Object
93
94
95
96
97
98
|
# File 'lib/rubyXL/objects/sheet_data.rb', line 93
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? ⇒ Boolean
68
69
70
71
72
|
# File 'lib/rubyXL/objects/sheet_data.rb', line 68
def is_date?
return false unless raw_value =~ /\A\d+(?:\.\d+)?\Z/ num_fmt = self.number_format
num_fmt && num_fmt.is_date_format?
end
|
64
65
66
|
# File 'lib/rubyXL/objects/sheet_data.rb', line 64
def number_format
workbook.stylesheet.get_number_format_by_id(get_cell_xf.num_fmt_id)
end
|
#raw_value ⇒ Object
55
56
57
|
# File 'lib/rubyXL/objects/sheet_data.rb', line 55
def raw_value
value_container && value_container.value
end
|
#raw_value=(v) ⇒ Object
59
60
61
62
|
# File 'lib/rubyXL/objects/sheet_data.rb', line 59
def raw_value=(v)
self.value_container ||= RubyXL::CellValue.new
value_container.value = v
end
|
#row ⇒ Object
39
40
41
|
# File 'lib/rubyXL/objects/sheet_data.rb', line 39
def row
r && r.first_row
end
|
#row=(v) ⇒ Object
43
44
45
|
# File 'lib/rubyXL/objects/sheet_data.rb', line 43
def row=(v)
self.r = RubyXL::Reference.new(v, column || 0)
end
|
#value(args = {}) ⇒ Object
Gets massaged value of the cell, converting datatypes to those known to Ruby (that includes stripping any special formatting from RichText).
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/rubyXL/objects/sheet_data.rb', line 76
def value(args = {})
if args[:raw] then
warn "[DEPRECATION] option :raw to `#{__method__}` is deprecated. Please use `raw_value` instead."
raw_value
elsif datatype == RubyXL::DataType::SHARED_STRING then
workbook.shared_strings_container[raw_value.to_i].to_s
elsif 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) if $1 then raw_value.to_f
else raw_value.to_i
end
else
raw_value
end
end
|