class OoxmlParser::XlsxRow

Single Row of XLSX

Attributes

cells_raw[R]

@return [Array<Cells>] cells of row, as in xml structure

custom_height[RW]

@return [True, False] true if the row height has been manually set.

height[RW]
hidden[RW]
index[RW]

@return [Integer] Indicates to which row in the sheet

this <row> definition corresponds.
style_index[R]

@return [Integer] index of style of row

Public Class Methods

new(parent: nil) click to toggle source
Calls superclass method OoxmlParser::OOXMLDocumentObject::new
# File lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row.rb, line 18
def initialize(parent: nil)
  @cells_raw = []
  @cells = []
  super
end

Public Instance Methods

cells() click to toggle source

@return [Array<XlsxCell, nil>] list of cell in row, with nil,

if cell data is not stored in xml
# File lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row.rb, line 53
def cells
  return @cells if @cells.any?

  cells_raw.each do |cell|
    @cells[cell.coordinates.column_number.to_i - 1] = cell
  end

  @cells
end
parse(node) click to toggle source

Parse XlsxRow object @param node [Nokogiri::XML:Element] node to parse @return [XlsxRow] result of parsing

# File lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row.rb, line 27
def parse(node)
  node.attributes.each do |key, value|
    case key
    when 'customHeight'
      @custom_height = option_enabled?(node, 'customHeight')
    when 'ht'
      @height = OoxmlSize.new(value.value.to_f, :point)
    when 'hidden'
      @hidden = option_enabled?(node, 'hidden')
    when 'r'
      @index = value.value.to_i
    when 's'
      @style_index = value.value.to_i
    end
  end
  node.xpath('*').each do |node_child|
    case node_child.name
    when 'c'
      @cells_raw << XlsxCell.new(parent: self).parse(node_child)
    end
  end
  self
end
style() click to toggle source

@return [Xf, nil] style of row or ‘nil` if not applied

# File lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row.rb, line 64
def style
  return nil unless @style_index

  root_object.style_sheet.cell_xfs.xf_array[@style_index]
end