Method: Axlsx::Cell#merge

Defined in:
lib/axlsx/workbook/worksheet/cell.rb

#merge(target) ⇒ Object

Merges all the cells in a range created between this cell and the cell or string name for a cell provided

Parameters:

  • target (Cell, String)

    The last cell, or str ref for the cell in the merge range

See Also:

  • Axlsx::Cell.worksheetworksheet.merge_cells


326
327
328
329
330
331
332
333
# File 'lib/axlsx/workbook/worksheet/cell.rb', line 326

def merge(target)
  start, stop = if target.is_a?(String)
                  [self.r, target]
                elsif(target.is_a?(Cell))
                  Axlsx.sort_cells([self, target]).map { |c| c.r }
                end
  self.row.worksheet.merge_cells "#{start}:#{stop}" unless stop.nil?
end