Sha256: 84bc6f863916907781413e8ea400cca5314e43249999e4685265b7311b1d3bf6
Contents?: true
Size: 1.6 KB
Versions: 3
Compression:
Stored size: 1.6 KB
Contents
# -*- coding: utf-8 -*- module Axlsx #This class specifies data for a particular data point. It is used for both numCache and numLit object class NumData # 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] attr_reader :format_code # creates a new NumVal object # @option options [String] formatCode # @option options [Array] :data # @see StrData def initialize(options={}) @format_code = "General" @pt = SimpleTypedList.new NumVal options.each do |o| self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}=" end end # 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. def data=(values=[]) @tag_name = values.first.is_a?(Cell) ? :numCache : :numLit values.each do |value| v = value.is_a?(Cell) ? value.value : value @pt << NumVal.new(:v => v) end end # @see format_code def format_code=(v='General') Axlsx::validate_string(v) @format_code = v end # serialize the object 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 end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
axlsx-1.1.6 | lib/axlsx/drawing/num_data.rb |
axlsx-1.1.5 | lib/axlsx/drawing/num_data.rb |
axlsx-1.1.4 | lib/axlsx/drawing/num_data.rb |