class OoxmlParser::TablePart

Class for `tablePart` data

Attributes

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

@return [ExtensionList] list of extensions

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/xlsx_data/view_model/workbook/worksheet/table_part.rb, line 21
def parse(node)
  link_to_table_part_xml = OOXMLDocumentObject.get_link_from_rels(node.attribute('id').value)
  doc = parse_xml(OOXMLDocumentObject.path_to_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