Class: OoxmlParser::PivotTableDefinition

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb

Overview

Class for parsing <PivotTableDefinition> tag

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, #boolean_attribute_value, #initialize, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

This class inherits a constructor from OoxmlParser::OOXMLDocumentObject

Instance Attribute Details

#apply_alignment_formatsTrue, False (readonly)

Returns should alignment formats be applied.

Returns:

  • (True, False)

    should alignment formats be applied



27
28
29
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb', line 27

def apply_alignment_formats
  @apply_alignment_formats
end

#apply_border_formatsTrue, False (readonly)

Returns should border formats be applied.

Returns:

  • (True, False)

    should border formats be applied



21
22
23
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb', line 21

def apply_border_formats
  @apply_border_formats
end

#apply_font_formatsTrue, False (readonly)

Returns should font formats be applied.

Returns:

  • (True, False)

    should font formats be applied



23
24
25
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb', line 23

def apply_font_formats
  @apply_font_formats
end

#apply_number_formatsTrue, False (readonly)

Returns should number formats be applied.

Returns:

  • (True, False)

    should number formats be applied



19
20
21
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb', line 19

def apply_number_formats
  @apply_number_formats
end

#apply_pattern_formatsTrue, False (readonly)

Returns should pattern formats be applied.

Returns:

  • (True, False)

    should pattern formats be applied



25
26
27
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb', line 25

def apply_pattern_formats
  @apply_pattern_formats
end

#apply_width_height_formatsTrue, False (readonly)

Returns should width height formats be applied.

Returns:

  • (True, False)

    should width height formats be applied



29
30
31
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb', line 29

def apply_width_height_formats
  @apply_width_height_formats
end

#cache_idInteger (readonly)

Returns id of cache.

Returns:

  • (Integer)

    id of cache



17
18
19
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb', line 17

def cache_id
  @cache_id
end

#column_fieldsRowFields (readonly)

Returns column fields.

Returns:



63
64
65
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb', line 63

def column_fields
  @column_fields
end

#column_itemsColumnRowItems (readonly)

Returns column items.

Returns:



51
52
53
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb', line 51

def column_items
  @column_items
end

#created_versionInteger (readonly)

Returns creation version.

Returns:

  • (Integer)

    creation version



37
38
39
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb', line 37

def created_version
  @created_version
end

#data_captionString (readonly)

Returns data caption.

Returns:

  • (String)

    data caption



35
36
37
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb', line 35

def data_caption
  @data_caption
end

#data_fieldsDataFields (readonly)

Returns data fields.

Returns:



57
58
59
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb', line 57

def data_fields
  @data_fields
end

#indentInteger (readonly)

Returns indent.

Returns:

  • (Integer)

    indent



39
40
41
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb', line 39

def indent
  @indent
end

#item_print_titlesTrue, False (readonly)

Returns should item print titles.

Returns:

  • (True, False)

    should item print titles



33
34
35
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb', line 33

def item_print_titles
  @item_print_titles
end

#locationLocation (readonly)

Returns location data.

Returns:



47
48
49
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb', line 47

def location
  @location
end

#multiple_field_filtersTrue, False (readonly)

Returns is there multiple fields filters.

Returns:

  • (True, False)

    is there multiple fields filters



45
46
47
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb', line 45

def multiple_field_filters
  @multiple_field_filters
end

#nameString (readonly)

Returns name of table.

Returns:

  • (String)

    name of table



15
16
17
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb', line 15

def name
  @name
end

#outlineTrue, False (readonly)

Returns outline.

Returns:

  • (True, False)

    outline



41
42
43
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb', line 41

def outline
  @outline
end

#outline_dataTrue, False (readonly)

Returns outline data.

Returns:

  • (True, False)

    outline data



43
44
45
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb', line 43

def outline_data
  @outline_data
end

#page_fieldsPageFields (readonly)

Returns page fields.

Returns:



59
60
61
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb', line 59

def page_fields
  @page_fields
end

#pivot_fieldsPivotFields (readonly)

Returns pivot fields.

Returns:



49
50
51
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb', line 49

def pivot_fields
  @pivot_fields
end

#row_fieldsRowFields (readonly)

Returns row fields.

Returns:



61
62
63
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb', line 61

def row_fields
  @row_fields
end

#row_itemsColumnRowItems (readonly)

Returns row items.

Returns:



53
54
55
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb', line 53

def row_items
  @row_items
end

#style_infoPivotTableStyleInfo (readonly)

Returns style info.

Returns:



55
56
57
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb', line 55

def style_info
  @style_info
end

#use_auto_formattingTrue, False (readonly)

Returns should auto formatting be used.

Returns:

  • (True, False)

    should auto formatting be used



31
32
33
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb', line 31

def use_auto_formatting
  @use_auto_formatting
end

Instance Method Details

#parse(file) ⇒ PivotTableDefinition

Parse PivotTableDefinition object

Parameters:

  • file (String)

    path

Returns:



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition.rb', line 68

def parse(file)
  doc = parse_xml("#{root_object.unpacked_folder}/#{file}")
  node = doc.xpath('//xmlns:pivotTableDefinition').first
  node.attributes.each do |key, value|
    case key
    when 'name'
      @name = value.value.to_s
    when 'cacheId'
      @cache_id = value.value.to_i
    when 'applyNumberFormats'
      @apply_number_formats = attribute_enabled?(value)
    when 'applyBorderFormats'
      @apply_border_formats = attribute_enabled?(value)
    when 'applyFontFormats'
      @apply_font_formats = attribute_enabled?(value)
    when 'applyPatternFormats'
      @apply_pattern_formats = attribute_enabled?(value)
    when 'applyAlignmentFormats'
      @apply_alignment_formats = attribute_enabled?(value)
    when 'applyWidthHeightFormats'
      @apply_width_height_formats = attribute_enabled?(value)
    when 'useAutoFormatting'
      @use_auto_formatting = attribute_enabled?(value)
    when 'itemPrintTitles'
      @item_print_titles = attribute_enabled?(value)
    when 'dataCaption'
      @data_caption = value.value.to_s
    when 'createdVersion'
      @created_version = value.value.to_i
    when 'indent'
      @indent = value.value.to_i
    when 'outline'
      @outline = attribute_enabled?(value)
    when 'outlineData'
      @outline_data = attribute_enabled?(value)
    when 'multipleFieldFilters'
      @multiple_field_filters = attribute_enabled?(value)
    end
  end

  node.xpath('*').each do |node_child|
    case node_child.name
    when 'location'
      @location = Location.new(parent: self).parse(node_child)
    when 'pivotFields'
      @pivot_fields = PivotFields.new(parent: self).parse(node_child)
    when 'rowItems'
      @row_items = ColumnRowItems.new(parent: self).parse(node_child)
    when 'colItems'
      @column_items = ColumnRowItems.new(parent: self).parse(node_child)
    when 'pivotTableStyleInfo'
      @style_info = PivotTableStyleInfo.new(parent: self).parse(node_child)
    when 'dataFields'
      @data_fields = DataFields.new(parent: self).parse(node_child)
    when 'pageFields'
      @page_fields = PageFields.new(parent: self).parse(node_child)
    when 'rowFields'
      @row_fields = RowFields.new(parent: self).parse(node_child)
    when 'colFields'
      @column_fields = RowFields.new(parent: self).parse(node_child)
    end
  end
  self
end