Class: OoxmlParser::TablePart

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part.rb

Overview

Class for ‘tablePart` data

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, add_to_xmls_stack, copy_file_and_rename_to_zip, current_xml, dir, encrypted_file?, get_link_from_rels, #initialize, unzip_file, #with_data?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

This class inherits a constructor from OoxmlParser::OOXMLDocumentObject

Instance Attribute Details

#autofilterObject

Returns the value of attribute autofilter.



7
8
9
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part.rb', line 7

def autofilter
  @autofilter
end

#columnsObject

Returns the value of attribute columns.



7
8
9
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part.rb', line 7

def columns
  @columns
end

#display_nameObject

Returns the value of attribute display_name.



7
8
9
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part.rb', line 7

def display_name
  @display_name
end

#extension_listExtensionList

Returns list of extensions.

Returns:



9
10
11
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part.rb', line 9

def extension_list
  @extension_list
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part.rb', line 7

def name
  @name
end

#referenceObject

Returns the value of attribute reference.



7
8
9
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part.rb', line 7

def reference
  @reference
end

#table_style_infoTableStyleInfo

Returns describe style of table.

Returns:



11
12
13
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part.rb', line 11

def table_style_info
  @table_style_info
end

Instance Method Details

#parse(node) ⇒ TablePart

Parse TablePart object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part.rb', line 16

def parse(node)
  link_to_table_part_xml = OOXMLDocumentObject.get_link_from_rels(node.attribute('id').value)
  doc = Nokogiri::XML(File.open(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 'tableStyleInfo'
      @table_style_info = TableStyleInfo.new(parent: self).parse(node_child)
    end
  end
  self
end