The Column class. Encapsulates column-formatting and width, and provides a means to iterate over all cells in a column.
Useful Attributes:
The width in characters (in respect to the ‘0’ character of the Worksheet’s default Font). Float values are permitted, for Excel the available Precision is at 1/256 characters.
The default Format for cells in this column (applied if there is no explicit Cell Format and no default Row format for the Cell).
The Column is hidden.
The Column is collapsed.
Outline level of the column.
# File lib/spreadsheet/column.rb, line 41 def initialize idx, format, opts={} @worksheet = nil @idx = idx opts[:width] ||= 10 opts.each do |key, value| self.send "#{key}=", value end self.default_format = format end
# File lib/spreadsheet/column.rb, line 21 def updater *keys keys.each do |key| unless instance_methods.include? "unupdated_#{key}=" alias_method :"unupdated_#{key}=", :"#{key}=" define_method "#{key}=" do |value| send "unupdated_#{key}=", value @worksheet.column_updated @idx, self if @worksheet value end end end end
Iterate over all cells in this column.
# File lib/spreadsheet/column.rb, line 60 def each @worksheet.each do |row| yield row[idx] end end