Class: Axlsx::NumData
- Inherits:
-
Object
- Object
- Axlsx::NumData
- Defined in:
- lib/axlsx/drawing/num_data.rb
Overview
This class specifies data for a particular data point. It is used for both numCache and numLit object
Instance Attribute Summary collapse
-
#format_code ⇒ String
A string representing the format code to apply.
Instance Method Summary collapse
-
#data=(values = []) ⇒ Object
Creates the val objects for this data set.
-
#initialize(options = {}) ⇒ NumData
constructor
creates a new NumVal object.
-
#to_xml_string(str = "") ⇒ Object
serialize the object.
Constructor Details
Instance Attribute Details
#format_code ⇒ String
A string representing the format code to apply. For more information see see the SpreadsheetML numFmt element's (ยง18.8.30) formatCode attribute.
9 10 11 |
# File 'lib/axlsx/drawing/num_data.rb', line 9 def format_code @format_code end |
Instance Method Details
#data=(values = []) ⇒ Object
Creates the val objects for this data set. I am not overly confident this is going to play nicely with time and data types.
25 26 27 28 29 30 31 |
# File 'lib/axlsx/drawing/num_data.rb', line 25 def data=(values=[]) @tag_name = values.first.is_a?(Cell) ? :numCache : :numLit values.each do |value| value = value.is_formula? ? 0 : value.value if value.is_a?(Cell) @pt << NumVal.new(:v => value) end end |
#to_xml_string(str = "") ⇒ Object
serialize the object
40 41 42 43 44 45 46 47 48 |
# File 'lib/axlsx/drawing/num_data.rb', line 40 def to_xml_string(str = "") str << '<c:' << @tag_name.to_s << '>' str << '<c:formatCode>' << format_code.to_s << '</c:formatCode>' str << '<c:ptCount val="' << @pt.size.to_s << '"/>' @pt.each_with_index do |num_val, index| num_val.to_xml_string index, str end str << '</c:' << @tag_name.to_s << '>' end |