Class: Axlsx::Cols

Inherits:
SimpleTypedList
  • Object
show all
Defined in:
lib/axlsx/workbook/worksheet/cols.rb

Overview

The cols class manages the col object used to manage column widths. This is where the magic happens with autowidth

Instance Method Summary collapse

Constructor Details

#initialize(worksheet) ⇒ Cols

Returns a new instance of Cols.

Raises:

  • (ArgumentError)


7
8
9
10
11
# File 'lib/axlsx/workbook/worksheet/cols.rb', line 7

def initialize(worksheet)
  raise ArgumentError, "you must provide a worksheet" unless worksheet.is_a?(Worksheet)
  super Col
  @worksheet = worksheet
end

Instance Method Details

#to_xml_string(str = '') ⇒ String

Serialize the Cols object

Parameters:

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

Returns:

  • (String)


16
17
18
19
20
21
# File 'lib/axlsx/workbook/worksheet/cols.rb', line 16

def to_xml_string(str = '')
 return if empty?
 str << '<cols>'
 each { |item| item.to_xml_string(str) }
 str << '</cols>'
end