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)



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)



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)



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)



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)



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)



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)



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)



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)



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)



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)



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)



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

def data_fields
  @data_fields
end

#indentInteger (readonly)



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)



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)



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)



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)



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

def name
  @name
end

#outlineTrue, False (readonly)



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

def outline
  @outline
end

#outline_dataTrue, False (readonly)



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)



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)



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)



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)



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)



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)



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



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