class OoxmlParser::PivotCacheDefinition

Class for parsing <pivotCacheDefinition> file

Attributes

cache_fields[R]

@return [CacheFields] fields of pivot cache

cache_source[R]

@return [CacheSource] source of pivot cache

id[R]

@return [String] id of pivot cache definition

Public Instance Methods

parse(file) click to toggle source

Parse PivotCacheDefinition file @param file [String] path to file @return [PivotCacheDefinition]

# File lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition.rb, line 19
def parse(file)
  return nil unless File.exist?(file)

  document = parse_xml(file)
  node = document.xpath('*').first

  node.attributes.each do |key, value|
    case key
    when 'id'
      @id = value.value.to_s
    end
  end

  node.xpath('*').each do |node_child|
    case node_child.name
    when 'cacheSource'
      @cache_source = CacheSource.new(parent: self).parse(node_child)
    when 'cacheFields'
      @cache_fields = CacheFields.new(parent: self).parse(node_child)
    end
  end
  self
end