Class: OoxmlParser::XlsxTable

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

Constant Summary

Constants inherited from OOXMLDocumentObject

OOXMLDocumentObject::DEFAULT_DIRECTORY_FOR_MEDIA

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, add_to_xmls_stack, copy_file_and_rename_to_zip, copy_media_file, current_xml, dir, encrypted_file?, get_link_from_rels, media_folder, option_enabled?, unzip_file

Instance Attribute Details

#autofilterObject

Returns the value of attribute autofilter.



4
5
6
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_table.rb', line 4

def autofilter
  @autofilter
end

#columnsObject

Returns the value of attribute columns.



4
5
6
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_table.rb', line 4

def columns
  @columns
end

#display_nameObject

Returns the value of attribute display_name.



4
5
6
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_table.rb', line 4

def display_name
  @display_name
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_table.rb', line 4

def name
  @name
end

#referenceObject

Returns the value of attribute reference.



4
5
6
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_table.rb', line 4

def reference
  @reference
end

Class Method Details

.parse(table_part_node) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_table.rb', line 6

def self.parse(table_part_node)
  table = XlsxTable.new
  link_to_table_part_xml = OOXMLDocumentObject.get_link_from_rels(table_part_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'
      table.name = value.value.to_s
    when 'displayName'
      table.display_name = value.value.to_s
    when 'ref'
      table.reference = Coordinates.parser_coordinates_range value.value.to_s
    end
  end
  table_node.xpath('*').each do |table_node_child|
    case table_node_child.name
    when 'autoFilter'
      table.autofilter = Coordinates.parser_coordinates_range table_node_child.attribute('ref').value
    end
  end
  table
end