Class: OoxmlParser::TablePart

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/xlsx_parser/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

#==, #boolean_attribute_value, #initialize, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

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.



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

def autofilter
  @autofilter
end

#columnsObject

Returns the value of attribute columns.



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

def columns
  @columns
end

#display_nameObject

Returns the value of attribute display_name.



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

def display_name
  @display_name
end

#extension_listExtensionList

Returns list of extensions.

Returns:



14
15
16
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part.rb', line 14

def extension_list
  @extension_list
end

#idString (readonly)

Returns id of table part.

Returns:

  • (String)

    id of table part



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

def id
  @id
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#referenceObject

Returns the value of attribute reference.



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

def reference
  @reference
end

#table_columnsTableColumns (readonly)

Returns list of table columns.

Returns:



16
17
18
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part.rb', line 16

def table_columns
  @table_columns
end

#table_style_infoTableStyleInfo

Returns describe style of table.

Returns:



18
19
20
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part.rb', line 18

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:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# 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