diff options
| author | Randy Morgan <[email protected]> | 2012-02-28 14:17:17 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-02-28 14:17:17 +0900 |
| commit | f43f801b9e01249dfde0bc8453ecf5376898d3c2 (patch) | |
| tree | 187a96fd310fbb6c07a3d60af7b22a3abeacf312 /lib/axlsx/workbook/worksheet/row.rb | |
| parent | 57f4162adb1984cc19e41833c32b9dcbf211a4c9 (diff) | |
| download | caxlsx-f43f801b9e01249dfde0bc8453ecf5376898d3c2.tar.gz caxlsx-f43f801b9e01249dfde0bc8453ecf5376898d3c2.zip | |
patching time converter and specs as well as fixing warnings related to uninitialized row#height and worksheet#page_margins
Diffstat (limited to 'lib/axlsx/workbook/worksheet/row.rb')
| -rw-r--r-- | lib/axlsx/workbook/worksheet/row.rb | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/lib/axlsx/workbook/worksheet/row.rb b/lib/axlsx/workbook/worksheet/row.rb index e24514bc..bb6a92a8 100644 --- a/lib/axlsx/workbook/worksheet/row.rb +++ b/lib/axlsx/workbook/worksheet/row.rb @@ -39,12 +39,13 @@ module Axlsx # If the style option is not defined, the default style (0) is applied to each cell. # @param [Worksheet] worksheet # @option options [Array] values - # @option options [Array, Symbol] types - # @option options [Array, Integer] style + # @option options [Array, Symbol] types + # @option options [Array, Integer] style # @option options [Float] height the row's height (in points) # @see Row#array_to_cells # @see Cell def initialize(worksheet, values=[], options={}) + @height = nil self.worksheet = worksheet @cells = SimpleTypedList.new Cell @worksheet.rows << self @@ -54,17 +55,17 @@ module Axlsx # The index of this row in the worksheet # @return [Integer] - def index + def index worksheet.rows.index(self) end - + # Serializes the row # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to. # @return [String] def to_xml(xml) attrs = {:r => index+1} attrs.merge!(:customHeight => 1, :ht => height) if custom_height? - xml.row(attrs) { |xml| @cells.each { |cell| cell.to_xml(xml) } } + xml.row(attrs) { |ixml| @cells.each { |cell| cell.to_xml(ixml) } } end # Adds a singel sell to the row based on the data provided and updates the worksheet's autofit data. @@ -74,7 +75,7 @@ module Axlsx update_auto_fit_data c end - + # sets the style for every cell in this row def style=(style) cells.each_with_index do | cell, index | @@ -84,7 +85,7 @@ module Axlsx end # returns the cells in this row as an array - # This lets us transpose the rows into columns + # This lets us transpose the rows into columns # @return [Array] def to_ary @cells.to_ary @@ -104,7 +105,7 @@ module Axlsx # assigns the owning worksheet for this row def worksheet=(v) DataTypeValidator.validate "Row.worksheet", Worksheet, v; @worksheet=v; end - + # Tell the worksheet to update autofit data for the columns based on this row's cells. # @return [SimpleTypedList] def update_auto_fit_data @@ -119,13 +120,13 @@ module Axlsx # If the style option is defined and is an Integer, it is applied to all cells created. # If the style option is an array, style is applied by index for each cell. # @option options [Array] values - # @option options [Array, Symbol] types - # @option options [Array, Integer] style + # @option options [Array, Symbol] types + # @option options [Array, Integer] style def array_to_cells(values, options={}) values = values DataTypeValidator.validate 'Row.array_to_cells', Array, values types, style = options.delete(:types), options.delete(:style) - values.each_with_index do |value, index| + values.each_with_index do |value, index| cell_style = style.is_a?(Array) ? style[index] : style options[:style] = cell_style if cell_style cell_type = types.is_a?(Array)? types[index] : types @@ -134,5 +135,5 @@ module Axlsx end end end - + end |
