Class: Excel::Column
- Inherits:
-
Object
- Object
- Excel::Column
- Defined in:
- lib/rexcel/column.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Identifier of column.
-
#title ⇒ Object
readonly
Used for title line in Excel.
Instance Method Summary collapse
-
#initialize(id, options = {}) ⇒ Column
constructor
Define identifier and optional other values.
-
#to_xls ⇒ Object
Fill an Excel Columns Receives a OLE-cell and optional a row.
-
#to_xml(xmlbuilder, ns) ⇒ Object
Build the xml a work sheet column.
Constructor Details
#initialize(id, options = {}) ⇒ Column
Define identifier and optional other values.
*title: Used for title line. Default: ID
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rexcel/column.rb', line 8 def initialize( id, = {}) @id = id @title = id .each{|key, value| case key when :title; @title = value.respond_to?(:encode) ? value.encode('utf-8') : value when :width if value.is_a?(Numeric) @width = value elsif value.respond_to?(:to_i) @width = value.to_i else raise ArgumentError, "Width is no Numeric" end raise ArgumentError, "Length zero or less" if @width <= 0 when :style raise ArgumentError unless value.is_a?(Style) @style = value else @log.error("#{self.class}: Undefined option #{key}") end } end |
Instance Attribute Details
#id ⇒ Object (readonly)
Identifier of column. Used for ruby internal reference
32 33 34 |
# File 'lib/rexcel/column.rb', line 32 def id @id end |
#title ⇒ Object (readonly)
Used for title line in Excel
34 35 36 |
# File 'lib/rexcel/column.rb', line 34 def title @title end |
Instance Method Details
#to_xls ⇒ Object
Fill an Excel Columns Receives a OLE-cell and optional a row.
57 58 59 |
# File 'lib/rexcel/column.rb', line 57 def to_xls() @log.fatal("Not implemented yet") end |
#to_xml(xmlbuilder, ns) ⇒ Object
Build the xml a work sheet column.
ns must be a method-object to implement the namespace definitions.
Format options (bold, italic, colors) are forwarded to cells.
43 44 45 46 47 48 49 |
# File 'lib/rexcel/column.rb', line 43 def to_xml(xmlbuilder, ns) = {} [ns.call('Width')] = @width if @width [ns.call('StyleID')] = @style.style_id if @style xmlbuilder[ns.call].Column( ) end |