ApiTable
Class representing a table.
Methods
Name |
Description |
AddColumn |
Adds a new column to the end of the current table. |
AddElement |
Adds a paragraph or a table or a blockLvl content control using its position in the cell. |
AddRow |
Adds a new row to the current table. |
Copy |
Creates a copy of the current table. |
GetClassType |
Returns the type of the ApiTable object. |
GetRow |
Returns a row by its index. |
MergeCells |
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. |
RemoveColumn |
Removes a table column with the specified cell. |
RemoveRow |
Removes a table row with the specified cell. |
Select |
Selects the current table. |
SetShd |
Specifies the shading which shall be applied to the extents of the current table. |
SetTableLook |
Specifies 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. |
ToJSON |
Converts the ApiTable object into the JSON object. |
Example
Copy code
builder.CreateFile("pptx");
var oPresentation = Api.GetPresentation();
var oTable = Api.CreateTable(3, 4);
var oRow = oTable.GetRow(0);
var oCell = oRow.GetCell(0);
oTable.RemoveColumn(oCell);
oRow = oTable.GetRow(3);
oCell = oRow.GetCell(0);
oTable.RemoveRow(oCell);
oRow = oTable.GetRow(0);
var oCell1 = oRow.GetCell(0);
var oCell2 = oRow.GetCell(1);
oTable.MergeCells([oCell1, oCell2]);
oCell = oRow.GetCell(0);
var oContent = oCell.GetContent();
var 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);
var oFill = Api.CreateSolidFill(Api.CreateRGBColor(255, 111, 61));
oTable.SetShd(oFill);
var oSlide = oPresentation.GetSlideByIndex(0);
oSlide.RemoveAllObjects();
oSlide.AddObject(oTable);
builder.SaveFile("pptx", "ApiTable.pptx");
builder.CloseFile();
Resulting document