Class: XlsxWriter::Row

Inherits:
Object
  • Object
show all
Defined in:
lib/xlsx_writer/row.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sheet, columns) ⇒ Row

Returns a new instance of Row.



7
8
9
10
11
12
13
# File 'lib/xlsx_writer/row.rb', line 7

def initialize(sheet, columns)
  @width = {}
  @sheet = sheet
  @cells = columns.map do |column|
    Cell.new self, column
  end
end

Instance Attribute Details

#cellsObject (readonly)

Returns the value of attribute cells.



4
5
6
# File 'lib/xlsx_writer/row.rb', line 4

def cells
  @cells
end

#sheetObject (readonly)

Returns the value of attribute sheet.



3
4
5
# File 'lib/xlsx_writer/row.rb', line 3

def sheet
  @sheet
end

#widthObject (readonly)

Returns the value of attribute width.



5
6
7
# File 'lib/xlsx_writer/row.rb', line 5

def width
  @width
end

Instance Method Details

#cell_width(x) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/xlsx_writer/row.rb', line 23

def cell_width(x)
  @width[x] ||= if (cell = cells[x])
    cell.pixel_width
  else
    0
  end
end

#lengthObject



19
20
21
# File 'lib/xlsx_writer/row.rb', line 19

def length
  cells.length
end

#ndxObject



15
16
17
# File 'lib/xlsx_writer/row.rb', line 15

def ndx
  sheet.rows.index(self) + 1
end

#to_xmlObject



31
32
33
34
35
36
37
38
39
# File 'lib/xlsx_writer/row.rb', line 31

def to_xml
  ary = []
  ary << %{<row r="#{ndx}">}
  cells.each do |cell|
    ary << cell.to_xml
  end
  ary << %{</row>}
  ary.join
end