class OoxmlParser::DataField

Class for parsing <dataField> tag

Attributes

base_field[RW]

@return [Integer] index of the base field for the ShowDataAs calculation

base_item[RW]

@return [Integer] index of the base item for the ShowDataAs calculation

extension_list[RW]

@return [ExtensionList] list of extensions

field[RW]

@return [Integer] index of the field in the pivotCacheRecords

name[R]

@return [String] name of the data field

number_format_id[RW]

@return [Integer] index of the number format applied to data field

Public Instance Methods

parse(node) click to toggle source

Parse ‘<dataField>` tag # @param [Nokogiri::XML:Element] node with DataField data @return [DataField]

# File lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/data_fields/data_field.rb, line 22
def parse(node)
  node.attributes.each do |key, value|
    case key
    when 'baseField'
      @base_field = value.value.to_i
    when 'baseItem'
      @base_item = value.value.to_i
    when 'fld'
      @field = value.value.to_i
    when 'name'
      @name = value.value.to_s
    when 'numFmtId'
      @number_format_id = value.value.to_i
    end
  end

  node.xpath('*').each do |node_child|
    case node_child.name
    when 'extLst'
      @extension_list = ExtensionList.new(parent: self).parse(node_child)
    end
  end
  self
end