TRY NEW VERSION

Try now New API BETA

Try out the new view and capabilities of the API documentation

START

MergeCells

MergeCells(aCells) → { ApiTableCell }

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

Parameters:

Name Type Description
aCells Array.<ApiTableCell>

The array of cells.

Returns:

Type
ApiTableCell

Example

Copy code
builder.CreateFile("pptx");
var oPresentation = Api.GetPresentation();
var oTable = Api.CreateTable(2, 4);
var oRow = oTable.GetRow(0);
var oCell1 = oRow.GetCell(0);
var oCell2 = oRow.GetCell(1);
oTable.MergeCells([oCell1, oCell2]);
var oCell = oRow.GetCell(0);
var oContent = oCell.GetContent();
var oParagraph = Api.CreateParagraph();
oParagraph.AddText("This cell was formed by merging two cells.");
oContent.Push(oParagraph);
var oSlide = oPresentation.GetSlideByIndex(0);
oSlide.RemoveAllObjects();
oSlide.AddObject(oTable);
builder.SaveFile("pptx", "MergeCells.pptx");
builder.CloseFile();

Resulting document