Class: Axlsx::Col
- Inherits:
-
Object
- Object
- Axlsx::Col
- Includes:
- OptionsParser, SerializedAttributes
- Defined in:
- lib/axlsx/workbook/worksheet/col.rb
Overview
The Col class defines column attributes for columns in sheets.
Instance Attribute Summary collapse
-
#best_fit ⇒ Boolean
(also: #bestFit)
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.
-
#custom_width ⇒ Boolean
(also: #customWidth)
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.
-
#outline_level ⇒ Integer
(also: #outlineLevel)
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.
-
#update_width(cell, fixed_width = nil, use_autowidth = true) ⇒ Object
updates the width for this col based on the cells autowidth and an optionally specified fixed width to this value and the cell’s attributes are ignored.
Methods included from SerializedAttributes
#declared_attributes, included, #serialized_attributes, #serialized_element_attributes, #serialized_tag
Methods included from OptionsParser
Constructor Details
#initialize(min, max, options = {}) ⇒ Col
Create a new Col objects
18 19 20 21 22 23 24 |
# File 'lib/axlsx/workbook/worksheet/col.rb', line 18 def initialize(min, max, ={}) Axlsx.validate_unsigned_int(max) Axlsx.validate_unsigned_int(min) @min = min @max = max end |
Instance Attribute Details
#best_fit ⇒ Boolean (readonly) Also known as: bestFit
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]
41 42 43 |
# File 'lib/axlsx/workbook/worksheet/col.rb', line 41 def best_fit @best_fit end |
#collapsed ⇒ Boolean
Flag indicating if the outlining of the affected column(s) is in the collapsed state.
46 47 48 |
# File 'lib/axlsx/workbook/worksheet/col.rb', line 46 def collapsed @collapsed end |
#custom_width ⇒ Boolean (readonly) Also known as: customWidth
70 71 72 |
# File 'lib/axlsx/workbook/worksheet/col.rb', line 70 def custom_width @custom_width end |
#hidden ⇒ Boolean
Flag indicating if the affected column(s) are hidden on this worksheet.
50 51 52 |
# File 'lib/axlsx/workbook/worksheet/col.rb', line 50 def hidden @hidden end |
#max ⇒ Integer (readonly)
Last column affected by this ‘column info’ record.
34 35 36 |
# File 'lib/axlsx/workbook/worksheet/col.rb', line 34 def max @max end |
#min ⇒ Integer (readonly)
First column affected by this ‘column info’ record.
30 31 32 |
# File 'lib/axlsx/workbook/worksheet/col.rb', line 30 def min @min end |
#outline_level ⇒ Integer Also known as: outlineLevel
Outline level of affected column(s). Range is 0 to 7.
54 55 56 |
# File 'lib/axlsx/workbook/worksheet/col.rb', line 54 def outline_level @outline_level end |
#phonetic ⇒ Boolean
Flag indicating if the phonetic information should be displayed by default for the affected column(s) of the worksheet.
59 60 61 |
# File 'lib/axlsx/workbook/worksheet/col.rb', line 59 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.
63 64 65 |
# File 'lib/axlsx/workbook/worksheet/col.rb', line 63 def style @style end |
#width ⇒ Numeric
The width of the column
67 68 69 |
# File 'lib/axlsx/workbook/worksheet/col.rb', line 67 def width @width end |
Instance Method Details
#to_xml_string(str = '') ⇒ String
Serialize this columns data to an xml string
136 137 138 |
# File 'lib/axlsx/workbook/worksheet/col.rb', line 136 def to_xml_string(str = '') serialized_tag('col', str) end |
#update_width(cell, fixed_width = nil, use_autowidth = true) ⇒ Object
updates the width for this col based on the cells autowidth and an optionally specified fixed width to this value and the cell’s attributes are ignored. autowidth value will be ignored.
124 125 126 127 128 129 130 131 |
# File 'lib/axlsx/workbook/worksheet/col.rb', line 124 def update_width(cell, fixed_width=nil, use_autowidth=true) if fixed_width.is_a? Numeric self.width = fixed_width elsif use_autowidth cell_width = cell.autowidth self.width = cell_width unless (width || 0) > (cell_width || 0) end end |