Class: OpenXml::Xlsx::Parts::Table
- Inherits:
-
Part
- Object
- Part
- OpenXml::Xlsx::Parts::Table
- Defined in:
- lib/openxml/xlsx/parts/table.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#ref ⇒ Object
readonly
Returns the value of attribute ref.
Instance Method Summary collapse
- #filename ⇒ Object
-
#initialize(id, name, ref, columns) ⇒ Table
constructor
A new instance of Table.
- #to_xml ⇒ Object
Constructor Details
#initialize(id, name, ref, columns) ⇒ Table
Returns a new instance of Table.
7 8 9 10 11 12 |
# File 'lib/openxml/xlsx/parts/table.rb', line 7 def initialize(id, name, ref, columns) @id = id @name = name @ref = ref @columns = columns end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
5 6 7 |
# File 'lib/openxml/xlsx/parts/table.rb', line 5 def columns @columns end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/openxml/xlsx/parts/table.rb', line 5 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/openxml/xlsx/parts/table.rb', line 5 def name @name end |
#ref ⇒ Object (readonly)
Returns the value of attribute ref.
5 6 7 |
# File 'lib/openxml/xlsx/parts/table.rb', line 5 def ref @ref end |
Instance Method Details
#filename ⇒ Object
14 15 16 |
# File 'lib/openxml/xlsx/parts/table.rb', line 14 def filename "table#{id}.xml" end |
#to_xml ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/openxml/xlsx/parts/table.rb', line 18 def to_xml build_standalone_xml do |xml| xml.table(xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main", id: id, name: name, displayName: name, ref: ref, totalsRowShown: 0) do xml.autoFilter ref: ref xml.tableColumns(count: columns.length) do columns.each_with_index do |column, index| xml.tableColumn(id: index + 1, name: column.name) end end xml.tableStyleInfo(name: "TableStyleLight6", showFirstColumn: 0, showLastColumn: 0, showRowStripes: 1, showColumnStripes: 0) end end end |