class OoxmlParser::TablePart

Class for ‘tablePart` data

Attributes

autofilter[RW]
columns[RW]
display_name[RW]
extension_list[RW]

@return [ExtensionList] list of extensions

id[R]

@return [String] id of table part

name[RW]
reference[RW]
table_columns[R]

@return [TableColumns] list of table columns

table_style_info[RW]

@return [TableStyleInfo] describe style of table

Public Instance Methods

parse(node) click to toggle source

Parse TablePart object @param node [Nokogiri::XML:Element] node to parse @return [TablePart] result of parsing

# File lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part.rb, line 23
def parse(node)
  node.attributes.each do |key, value|
    case key
    when 'id'
      @id = value.value.to_s
    end
  end
  link_to_table_part_xml = root_object.get_link_from_rels(@id)
  doc = parse_xml(root_object.unpacked_folder + link_to_table_part_xml.gsub('..', 'xl'))
  table_node = doc.xpath('xmlns:table').first
  table_node.attributes.each do |key, value|
    case key
    when 'name'
      @name = value.value.to_s
    when 'displayName'
      @display_name = value.value.to_s
    when 'ref'
      @reference = Coordinates.parser_coordinates_range value.value.to_s
    end
  end
  table_node.xpath('*').each do |node_child|
    case node_child.name
    when 'autoFilter'
      @autofilter = Autofilter.new(parent: self).parse(node_child)
    when 'extLst'
      @extension_list = ExtensionList.new(parent: self).parse(node_child)
    when 'tableColumns'
      @table_columns = TableColumns.new(parent: self).parse(node_child)
    when 'tableStyleInfo'
      @table_style_info = TableStyleInfo.new(parent: self).parse(node_child)
    end
  end
  self
end