Sha256: 322c9615896f6ab163e25d5ae31d1425cc93c93e13c007f3c0c86c22d9fb30ca

Contents?: true

Size: 1.47 KB

Versions: 6

Compression:

Stored size: 1.47 KB

Contents

module Axlsx
  # A single table style definition and is a collection for tableStyleElements
  # @note Table are not supported in this version and only the defaults required for a valid workbook are created.
  class TableStyle < SimpleTypedList

    # The name of this table style
    # @return [string]
    attr_accessor :name

    # indicates if this style should be applied to pivot tables
    # @return [Boolean]
    attr_accessor :pivot

    # indicates if this style should be applied to tables
    # @return [Boolean]
    attr_accessor :table

    # creates a new TableStyle object
    # @raise [ArgumentError] if name option is not provided.
    # @param [String] name
    # @option options [Boolean] pivot
    # @option options [Boolean] table
    def initialize(name, options={})
      options.each do |o|
        self.send("#{o[0]}=", o[1]) if self.respond_to? o[0]
      end
      super TableStyleElement
    end

    def name=(v) Axlsx::validate_string v; @name=v end
    def pivot=(v) Axlsx::validate_boolean v; @pivot=v end
    def table=(v) Axlsx::validate_boolean v; @table=v end

    # Serializes the table style
    # @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.select { |k, v| [:name, :pivot, :table].include? k }
      attr[:count] = self.size
      xml.tableStyle(attr) { self.each { |table_style_el| table_style_el.to_xml(xml) } }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
axlsx-1.0.7 lib/axlsx/stylesheet/table_style.rb~
axlsx-1.0.6 lib/axlsx/stylesheet/table_style.rb~
axlsx-1.0.5 lib/axlsx/stylesheet/table_style.rb~
axlsx-1.0.4 lib/axlsx/stylesheet/table_style.rb~
axlsx-1.0.3 lib/axlsx/stylesheet/table_style.rb~
axlsx-1.0.1 lib/axlsx/stylesheet/table_style.rb~