Class: RubyXL::Cell
Overview
Instance Attribute Summary
Attributes included from LegacyCell
#formula, #worksheet
Instance Method Summary
collapse
Methods included from LegacyCell
#border_bottom, #border_diagonal, #border_left, #border_right, #border_top, #change_border_bottom, #change_border_diagonal, #change_border_left, #change_border_right, #change_border_top, #change_contents, #change_fill, #change_font_bold, #change_font_color, #change_font_italics, #change_font_name, #change_font_size, #change_font_strikethrough, #change_font_underline, #change_horizontal_alignment, #change_text_wrap, #change_vertical_alignment, #fill_color, #font_color, #font_name, #font_size, #horizontal_alignment, #inspect, #is_bolded, #is_italicized, #is_struckthrough, #is_underlined, #text_wrap, #vertical_alignment, #workbook
#define_attribute, #define_child_node, #define_element_name, #obtain_class_variable, #parse, #set_countable
#before_write_xml, #dup, #initialize, #write_xml
Instance Method Details
#column ⇒ Object
45
46
47
|
# File 'lib/rubyXL/objects/sheet_data.rb', line 45
def column
r && r.first_col
end
|
#column=(v) ⇒ Object
49
50
51
|
# File 'lib/rubyXL/objects/sheet_data.rb', line 49
def column=(v)
self.r = RubyXL::Reference.new(row || 0, v)
end
|
#index_in_collection ⇒ Object
33
34
35
|
# File 'lib/rubyXL/objects/sheet_data.rb', line 33
def index_in_collection
r.col_range.begin
end
|
#is_date? ⇒ Boolean
66
67
68
69
70
|
# File 'lib/rubyXL/objects/sheet_data.rb', line 66
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
|
62
63
64
|
# File 'lib/rubyXL/objects/sheet_data.rb', line 62
def number_format
workbook.stylesheet.get_number_format_by_id(get_cell_xf.num_fmt_id)
end
|
#raw_value ⇒ Object
53
54
55
|
# File 'lib/rubyXL/objects/sheet_data.rb', line 53
def raw_value
value_container && value_container.value
end
|
#raw_value=(v) ⇒ Object
57
58
59
60
|
# File 'lib/rubyXL/objects/sheet_data.rb', line 57
def raw_value=(v)
self.value_container ||= RubyXL::CellValue.new
value_container.value = v
end
|
#row ⇒ Object
37
38
39
|
# File 'lib/rubyXL/objects/sheet_data.rb', line 37
def row
r && r.first_row
end
|
#row=(v) ⇒ Object
41
42
43
|
# File 'lib/rubyXL/objects/sheet_data.rb', line 41
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).
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/rubyXL/objects/sheet_data.rb', line 74
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) if $1 then raw_value.to_f
else raw_value.to_i
end
else raw_value
end
end
end
|