diff options
| author | Randy Morgan <[email protected]> | 2012-05-03 09:10:23 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-05-03 09:10:23 +0900 |
| commit | e622dc54069074198990beb0462da630bad38dd0 (patch) | |
| tree | 4065eb11cf4dcd68440bf8347af4509c130fb11e /lib/axlsx/drawing/str_data.rb | |
| parent | 2dfdd1f26b1fc748da3b4edad9aeeaeae842aedb (diff) | |
| download | caxlsx-e622dc54069074198990beb0462da630bad38dd0.tar.gz caxlsx-e622dc54069074198990beb0462da630bad38dd0.zip | |
rebuild series data base objects with full implementation.
Address shape validation error.
Diffstat (limited to 'lib/axlsx/drawing/str_data.rb')
| -rw-r--r-- | lib/axlsx/drawing/str_data.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/axlsx/drawing/str_data.rb b/lib/axlsx/drawing/str_data.rb new file mode 100644 index 00000000..cb4ff54f --- /dev/null +++ b/lib/axlsx/drawing/str_data.rb @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +module Axlsx + + #This specifies the last string data used for a chart. (e.g. strLit and strCache) + # This class is extended for NumData to include the formatCode attribute required for numLit and numCache + class StrData + + # creates a new StrVal object + # @option options [Array] :data + # @option options [String] :tag_name + def initialize(options={}) + @tag_prefix = :str + @type = StrVal + @pt = SimpleTypedList.new(@type) + 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) ? :strCache : :strLit + values.each do |value| + v = value.is_a?(Cell) ? value.value : value + @pt << @type.new(:v => v) + end + end + + # serialize the object + def to_xml_string(str = "") + str << '<c:' << @tag_name.to_s << '>' + str << '<c:ptCount val="' << @pt.size.to_s << '"/>' + @pt.each_with_index do |value, index| + value.to_xml_string index, str + end + str << '</c:' << @tag_name.to_s << '>' + end + + end + +end |
