class Axlsx::NumData

This class specifies data for a particular data point. It is used for both numCache and numLit object

Attributes

format_code[R]

A string representing the format code to apply. For more information see see the SpreadsheetML numFmt element's (ยง18.8.30) formatCode attribute. @return [String]

Public Class Methods

new(options={}) click to toggle source

creates a new NumVal object @option options [String] formatCode @option options [Array] :data @see StrData

# File lib/axlsx/drawing/num_data.rb, line 12
def initialize(options={})
  @format_code = "General"
  @pt = SimpleTypedList.new NumVal
  parse_options options
end

Public Instance Methods

data=(values=[]) click to toggle source

Creates the val objects for this data set. I am not overly confident this is going to play nicely with time and data types. @param [Array] values An array of cells or values.

# File lib/axlsx/drawing/num_data.rb, line 24
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
format_code=(v='General') click to toggle source

@see format_code

# File lib/axlsx/drawing/num_data.rb, line 33
def format_code=(v='General')
  Axlsx::validate_string(v)
  @format_code = v
end
to_xml_string(str = "") click to toggle source

serialize the object

# File lib/axlsx/drawing/num_data.rb, line 39
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