diff options
| author | Randy Morgan <[email protected]> | 2012-04-01 11:58:09 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-04-01 11:58:09 +0900 |
| commit | 1529fce32449a8454208fded20d83c9ceca810e0 (patch) | |
| tree | 02f722182fea58a51b8c0a5433221b3a677e80e4 /lib/axlsx/stylesheet/table_styles.rb | |
| parent | 22a341841f191a5aa00e87b1f166b4f25cc67f0a (diff) | |
| download | caxlsx-1529fce32449a8454208fded20d83c9ceca810e0.tar.gz caxlsx-1529fce32449a8454208fded20d83c9ceca810e0.zip | |
rebuild all serialization to use string concatenation instead of nokogiri.
Diffstat (limited to 'lib/axlsx/stylesheet/table_styles.rb')
| -rw-r--r-- | lib/axlsx/stylesheet/table_styles.rb | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/axlsx/stylesheet/table_styles.rb b/lib/axlsx/stylesheet/table_styles.rb index f0e9c904..5474c165 100644 --- a/lib/axlsx/stylesheet/table_styles.rb +++ b/lib/axlsx/stylesheet/table_styles.rb @@ -11,13 +11,13 @@ module Axlsx # The default pivot table style. The default value is 'PivotStyleLight6' # @return [String] attr_reader :defaultPivotStyle - + # Creates a new TableStyles object that is a container for TableStyle objects # @option options [String] defaultTableStyle # @option options [String] defaultPivotStyle def initialize(options={}) @defaultTableStyle = options[:defaultTableStyle] || "TableStyleMedium9" - @defaultPivotStyle = options[:defaultPivotStyle] || "PivotStyleLight16" + @defaultPivotStyle = options[:defaultPivotStyle] || "PivotStyleLight16" super TableStyle end # @see defaultTableStyle @@ -25,6 +25,17 @@ module Axlsx # @see defaultPivotStyle def defaultPivotStyle=(v) Axlsx::validate_string(v); @defaultPivotStyle = v; end + + def to_xml_string(str = '') + attr = self.instance_values.reject {|k, v| ![:defaultTableStyle, :defaultPivotStyle].include?(k.to_sym) } + attr[:count] = self.size + str << '<tableStyles ' + str << attr.map { |key, value| '' << key.to_s << '="' << value.to_s << '"' }.join(' ') + str << '>' + each { |table_style| table_style.to_xml_string(str) } + str << '</tableStyles>' + end + # Serializes the table styles element # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to. # @return [String] |
