Class: Axlsx::Col
- Inherits:
-
Object
- Object
- Axlsx::Col
- Defined in:
- lib/axlsx/workbook/worksheet/col.rb
Overview
The Col class defines column attributes for columns in sheets.
Instance Attribute Summary collapse
-
#bestFit ⇒ Boolean
readonly
Flag indicating if the specified column(s) is set to ‘best fit’.
-
#collapsed ⇒ Boolean
Flag indicating if the outlining of the affected column(s) is in the collapsed state.
- #customWidth ⇒ Boolean readonly
-
#hidden ⇒ Boolean
Flag indicating if the affected column(s) are hidden on this worksheet.
-
#max ⇒ Integer
readonly
Last column affected by this ‘column info’ record.
-
#min ⇒ Integer
readonly
First column affected by this ‘column info’ record.
-
#outlineLevel ⇒ Integer
Outline level of affected column(s).
-
#phonetic ⇒ Boolean
Flag indicating if the phonetic information should be displayed by default for the affected column(s) of the worksheet.
-
#style ⇒ Integer
Default style for the affected column(s).
-
#width ⇒ Numeric
The width of the column.
Instance Method Summary collapse
-
#initialize(min, max, options = {}) ⇒ Col
constructor
Create a new Col objects.
-
#to_xml_string(str = '') ⇒ String
Serialize this columns data to an xml string.
Constructor Details
#initialize(min, max, options = {}) ⇒ Col
Create a new Col objects
95 96 97 98 99 100 101 102 103 |
# File 'lib/axlsx/workbook/worksheet/col.rb', line 95 def initialize(min, max, ={}) Axlsx.validate_unsigned_int(max) Axlsx.validate_unsigned_int(min) @min = min @max = max .each do |o| self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}=" end end |
Instance Attribute Details
#bestFit ⇒ Boolean (readonly)
Flag indicating if the specified column(s) is set to ‘best fit’. ‘Best fit’ is set to true under these conditions: The column width has never been manually set by the user, AND The column width is not the default width ‘Best fit’ means that when numbers are typed into a cell contained in a ‘best fit’ column, the column width should
automatically resize to display the number. [Note: In best fit cases, column width must not be made smaller, only larger. end note]
20 21 22 |
# File 'lib/axlsx/workbook/worksheet/col.rb', line 20 def bestFit @bestFit end |
#collapsed ⇒ Boolean
Flag indicating if the outlining of the affected column(s) is in the collapsed state.
24 25 26 |
# File 'lib/axlsx/workbook/worksheet/col.rb', line 24 def collapsed @collapsed end |
#customWidth ⇒ Boolean (readonly)
47 48 49 |
# File 'lib/axlsx/workbook/worksheet/col.rb', line 47 def customWidth @customWidth end |
#hidden ⇒ Boolean
Flag indicating if the affected column(s) are hidden on this worksheet.
28 29 30 |
# File 'lib/axlsx/workbook/worksheet/col.rb', line 28 def hidden @hidden end |
#max ⇒ Integer (readonly)
Last column affected by this ‘column info’ record.
13 14 15 |
# File 'lib/axlsx/workbook/worksheet/col.rb', line 13 def max @max end |
#min ⇒ Integer (readonly)
First column affected by this ‘column info’ record.
9 10 11 |
# File 'lib/axlsx/workbook/worksheet/col.rb', line 9 def min @min end |
#outlineLevel ⇒ Integer
Outline level of affected column(s). Range is 0 to 7.
32 33 34 |
# File 'lib/axlsx/workbook/worksheet/col.rb', line 32 def outlineLevel @outlineLevel end |
#phonetic ⇒ Boolean
Flag indicating if the phonetic information should be displayed by default for the affected column(s) of the worksheet.
36 37 38 |
# File 'lib/axlsx/workbook/worksheet/col.rb', line 36 def phonetic @phonetic end |
#style ⇒ Integer
Default style for the affected column(s). Affects cells not yet allocated in the column(s). In other words, this style applies to new columns.
40 41 42 |
# File 'lib/axlsx/workbook/worksheet/col.rb', line 40 def style @style end |
#width ⇒ Numeric
The width of the column
44 45 46 |
# File 'lib/axlsx/workbook/worksheet/col.rb', line 44 def width @width end |
Instance Method Details
#to_xml_string(str = '') ⇒ String
Serialize this columns data to an xml string
108 109 110 111 |
# File 'lib/axlsx/workbook/worksheet/col.rb', line 108 def to_xml_string(str = '') attrs = self.instance_values.reject{ |key, value| value == nil } str << '<col ' << attrs.map { |key, value| '' << key << '="' << value.to_s << '"' }.join(' ') << '/>' end |