Sha256: 8136d168c535962577a1d0d1dc10d11ce837b614f18b5bb75d79e179b1ff916c

Contents?: true

Size: 1.63 KB

Versions: 8

Compression:

Stored size: 1.63 KB

Contents

module Axlsx
  # TableStyles represents a collection of style definitions for table styles and pivot table styles.
  # @note Support for custom table styles does not exist in this version. Many of the classes required are defined in preparation for future release. Please do not attempt to add custom table styles.
  class TableStyles < SimpleTypedList

    # The default table style. The default value is 'TableStyleMedium9'
    # @return [String]
    # 
    attr_accessor :defaultTableStyle

    # The default pivot table style. The default value is  'PivotStyleLight6'
    # @return [String]
    attr_accessor :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"      
      super TableStyle
    end

    def defaultTableStyle=(v) Axlsx::validate_string(v); @defaultTableStyle = v; end
    def defaultPivotStyle=(v) Axlsx::validate_string(v); @defaultPivotStyle = v; end

    # Serializes the table styles element
    # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
    # @return [String]
    def to_xml(xml)
      attr = self.instance_values.reject {|k, v| ![:defaultTableStyle, :defaultPivotStyle].include?(k.to_sym) }
      attr[:count] = self.size
      xml.tableStyles(attr) {
        self.each { |table_style| table_style.to_xml(xml) }
      }
    end
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
axlsx-1.0.8 lib/axlsx/stylesheet/table_styles.rb
axlsx-1.0.7 lib/axlsx/stylesheet/table_styles.rb
axlsx-1.0.6 lib/axlsx/stylesheet/table_styles.rb
axlsx-1.0.5 lib/axlsx/stylesheet/table_styles.rb
axlsx-1.0.4 lib/axlsx/stylesheet/table_styles.rb
axlsx-1.0.3 lib/axlsx/stylesheet/table_styles.rb
axlsx-1.0.1 lib/axlsx/stylesheet/table_styles.rb
axlsx-1.0.0 lib/axlsx/stylesheet/table_styles.rb