class OpenXml::Xlsx::Elements::Row

Attributes

cells[R]
height[R]
hidden[R]
number[R]
worksheet[R]

Public Class Methods

new(worksheet, options={}) click to toggle source
# File lib/openxml/xlsx/elements/row.rb, line 7
def initialize(worksheet, options={})
  @worksheet = worksheet
  @number = options.fetch(:number)
  @height = options[:height]
  @hidden = options[:hidden]
  @cells = []

  Array(options[:cells]).each do |attributes|
    add_cell attributes
  end
end

Public Instance Methods

add_cell(attributes) click to toggle source
# File lib/openxml/xlsx/elements/row.rb, line 19
def add_cell(attributes)
  cells.push Xlsx::Elements::Cell.new(self, attributes)
end
to_xml(xml) click to toggle source
# File lib/openxml/xlsx/elements/row.rb, line 23
def to_xml(xml)
  attributes = {"r" => number}
  attributes.merge!("ht" => height, "customHeight" => 1) if height
  attributes.merge!("hidden" => 1) if hidden
  xml.row(attributes) do
    cells.each do |cell|
      cell.to_xml(xml)
    end
  end
end