Class: Axlsx::TableStyle

Inherits:
SimpleTypedList
  • Object
show all
Includes:
OptionsParser, SerializedAttributes
Defined in:
lib/axlsx/stylesheet/table_style.rb

Overview

Note:

Table are not supported in this version and only the defaults required for a valid workbook are created.

A single table style definition and is a collection for tableStyleElements

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SerializedAttributes

included, #serialized_attributes, #serialized_element_attributes, #serialized_tag

Methods included from OptionsParser

#parse_options

Constructor Details

#initialize(name, options = {}) ⇒ TableStyle

creates a new TableStyle object

Parameters:

  • name (String)
  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • pivot (Boolean)
  • table (Boolean)

Raises:

  • (ArgumentError)

    if name option is not provided.



15
16
17
18
19
# File 'lib/axlsx/stylesheet/table_style.rb', line 15

def initialize(name, options = {})
  self.name = name
  parse_options options
  super(TableStyleElement)
end

Instance Attribute Details

#namestring

The name of this table style

Returns:

  • (string)


25
26
27
# File 'lib/axlsx/stylesheet/table_style.rb', line 25

def name
  @name
end

#pivotBoolean

indicates if this style should be applied to pivot tables

Returns:

  • (Boolean)


29
30
31
# File 'lib/axlsx/stylesheet/table_style.rb', line 29

def pivot
  @pivot
end

#tableBoolean

indicates if this style should be applied to tables

Returns:

  • (Boolean)


33
34
35
# File 'lib/axlsx/stylesheet/table_style.rb', line 33

def table
  @table
end

Instance Method Details

#to_xml_string(str = +'')) ⇒ String

Serializes the object

Parameters:

  • str (String) (defaults to: +''))

Returns:

  • (String)


56
57
58
59
60
61
62
# File 'lib/axlsx/stylesheet/table_style.rb', line 56

def to_xml_string(str = +'')
  str << '<tableStyle '
  serialized_attributes str, { count: size }
  str << '>'
  each { |table_style_el| table_style_el.to_xml_string(str) }
  str << '</tableStyle>'
end