Get Started
Usage API
More information

ApiTable

new ApiTable()

Class representing a table.

Methods

Name Description
AddColumn

Add a new column to the end of the current table.

AddElement

Add a paragraph or a table or a blockLvl content control using its position in the cell.

AddRow

Add a new row to the current table.

Copy

Create a copy of a table.

GetClassType

Return type of object.

GetRow

Return row by index.

MergeCells

Merge array of cells. If merge was done successfully, 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.

RemoveColumn

Remove the table column with a specified cell.

RemoveRow

Remove the table row with a specified cell.

Select

Select a table.

SetShd

Specify the shading which shall be applied to the extents of the current table.

SetTableLook

Specify the components of the conditional formatting of the referenced table style (if one exists) which shall be applied to the set of table rows with the current table-level property exceptions. A table style can specify up to six different optional conditional formats [Example: Different formatting for first column], which then can be applied or omitted from individual table rows in the parent table.

The default setting is to apply the row and column banding formatting, but not the first row, last row, first column, or last column formatting.

Example

Copy code
builder.CreateFile("pptx");
oPresentation = Api.GetPresentation();
oTable = Api.CreateTable(3, 4);
oRow = oTable.GetRow(0);
oCell = oRow.GetCell(0);
oTable.RemoveColumn(oCell);
oRow = oTable.GetRow(3);
oCell = oRow.GetCell(0);
oTable.RemoveRow(oCell);
oRow = oTable.GetRow(0);
oCell1 = oRow.GetCell(0);
oCell2 = oRow.GetCell(1);
oTable.MergeCells([oCell1, oCell2]);
oCell = oRow.GetCell(0);
oContent = oCell.GetContent();
oParagraph = Api.CreateParagraph();
oParagraph.AddText("The first column was removed. The fourth row was removed. And the cells of the first row were merged.");
oContent.Push(oParagraph);
oFill = Api.CreateSolidFill(Api.CreateRGBColor(520, 64, 1));
oTable.SetShd(oFill);
oSlide = oPresentation.GetSlideByIndex(0);
oSlide.RemoveAllObjects();
oSlide.AddObject(oTable);
builder.SaveFile("pptx", "ApiTable.pptx");
builder.CloseFile();

Resulting document