MergeCells

function MergeCells(aCells: ApiTableCell[] = null): ApiTableCell

Description

Merges an array of cells. If the merge is done successfully, it will return the resulting merged cell, otherwise the result will be "null". The number of cells in any row and the number of rows in the current table may be changed.

Parameters

aCellsApiTableCell[]default: null

The array of cells to be merged.

Returns

ApiTableCell

Try It

var oDocument = Api.GetDocument();
var oTableStyle = oDocument.CreateStyle("CustomTableStyle", "table");
oTableStyle.SetBasedOn(oDocument.GetStyle("Bordered"));
var oTable = Api.CreateTable(5, 5);
oTable.SetWidth("percent", 100);
oTable.SetStyle(oTableStyle);
var oCell = oTable.MergeCells([oTable.GetRow(1).GetCell(1), oTable.GetRow(1).GetCell(2), oTable.GetRow(2).GetCell(1), oTable.GetRow(2).GetCell(2)]);
oCell.GetContent().GetElement(0).AddText("Merged cell");
oDocument.Push(oTable);

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).