class OoxmlParser::PivotTableDefinition

Class for parsing <PivotTableDefinition> tag

Attributes

apply_alignment_formats[R]

@return [True, False] should alignment formats be applied

apply_border_formats[R]

@return [True, False] should border formats be applied

apply_font_formats[R]

@return [True, False] should font formats be applied

apply_number_formats[R]

@return [True, False] should number formats be applied

apply_pattern_formats[R]

@return [True, False] should pattern formats be applied

apply_width_height_formats[R]

@return [True, False] should width height formats be applied

cache_id[R]

@return [Integer] id of cache

column_fields[R]

@return [RowFields] column fields

column_items[R]

@return [ColumnRowItems] column items

created_version[R]

@return [Integer] creation version

data_caption[R]

@return [String] data caption

data_fields[R]

@return [DataFields] data fields

indent[R]

@return [Integer] indent

item_print_titles[R]

@return [True, False] should item print titles

location[R]

@return [Location] location data

multiple_field_filters[R]

@return [True, False] is there multiple fields filters

name[R]

@return [String] name of table

outline[R]

@return [True, False] outline

outline_data[R]

@return [True, False] outline data

page_fields[R]

@return [PageFields] page fields

pivot_fields[R]

@return [PivotFields] pivot fields

row_fields[R]

@return [RowFields] row fields

row_items[R]

@return [ColumnRowItems] row items

style_info[R]

@return [PivotTableStyleInfo] style info

use_auto_formatting[R]

@return [True, False] should auto formatting be used

Public Instance Methods

parse(file) click to toggle source

Parse PivotTableDefinition object @param [String] file path @return [PivotTableDefinition] result of parsing

# 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