Method: Axlsx::Table#to_xml_string

Defined in:
lib/axlsx/workbook/worksheet/table.rb

#to_xml_string(str = '') ⇒ String

Serializes the object

Parameters:

  • str (String) (defaults to: '')

Returns:

  • (String)


76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/axlsx/workbook/worksheet/table.rb', line 76

def to_xml_string(str = '')
  str << '<?xml version="1.0" encoding="UTF-8"?>'
  str << ('<table xmlns="' << XML_NS << '" id="' << (index+1).to_s << '" name="' << @name << '" displayName="' << @name.gsub(/\s/,'_') << '" ')
  str << ('ref="' << @ref << '" totalsRowShown="0">')
  str << ('<autoFilter ref="' << @ref << '"/>')
  str << ('<tableColumns count="' << header_cells.length.to_s << '">')
  header_cells.each_with_index do |cell,index|
    str << ('<tableColumn id ="' << (index+1).to_s << '" name="' << cell.value << '"/>')
  end
  str << '</tableColumns>'
  table_style_info.to_xml_string(str)
  str << '</table>'
end