Class: OoxmlParser::Table
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::Table
- Defined in:
- lib/ooxml_parser/common_parser/common_data/table.rb
Constant Summary
Constants inherited from OOXMLDocumentObject
OOXMLDocumentObject::DEFAULT_DIRECTORY_FOR_MEDIA
Instance Attribute Summary collapse
-
#grid ⇒ Object
Returns the value of attribute grid.
-
#number ⇒ Object
Returns the value of attribute number.
-
#properties ⇒ Object
(also: #table_properties)
Returns the value of attribute properties.
-
#rows ⇒ Object
Returns the value of attribute rows.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(rows = []) ⇒ Table
constructor
A new instance of Table.
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
Constructor Details
#initialize(rows = []) ⇒ Table
Returns a new instance of Table.
10 11 12 |
# File 'lib/ooxml_parser/common_parser/common_data/table.rb', line 10 def initialize(rows = []) @rows = rows end |
Instance Attribute Details
#grid ⇒ Object
Returns the value of attribute grid.
8 9 10 |
# File 'lib/ooxml_parser/common_parser/common_data/table.rb', line 8 def grid @grid end |
#number ⇒ Object
Returns the value of attribute number.
8 9 10 |
# File 'lib/ooxml_parser/common_parser/common_data/table.rb', line 8 def number @number end |
#properties ⇒ Object Also known as: table_properties
Returns the value of attribute properties.
8 9 10 |
# File 'lib/ooxml_parser/common_parser/common_data/table.rb', line 8 def properties @properties end |
#rows ⇒ Object
Returns the value of attribute rows.
8 9 10 |
# File 'lib/ooxml_parser/common_parser/common_data/table.rb', line 8 def rows @rows end |
Class Method Details
.parse(table_node, number = 0, default_table_properties = TableProperties.new, default_paragraph = DocxParagraph.new, default_run = DocxParagraphRun.new) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ooxml_parser/common_parser/common_data/table.rb', line 16 def self.parse(table_node, number = 0, default_table_properties = TableProperties.new, default_paragraph = DocxParagraph.new, default_run = DocxParagraphRun.new) table_properties = default_table_properties.copy table_properties.jc = :left table_paragraph = default_paragraph.copy table_character = default_run.copy table = Table.new table_node.xpath('*').each do |table_node_child| case table_node_child.name when 'tblGrid' table.grid = TableGrid.new table_node_child.xpath('gridCol').each do |grid_col_node| table.grid.columns << (grid_col_node.attribute('w').value.to_f / 360_000.0).round(2) end when 'tr' table.rows << TableRow.parse(table_node_child) when 'tblPr' table.properties = TableProperties.parse(table_node_child) when '' DocxParagraph.parse_paragraph_style(table_node_child, table_paragraph, table_character) end end table.number = number table end |