Get Started
Documentation

ApiTable

new ApiTable()

Class representing a table.

Extends

Name Description
ApiTablePr Class representing table properties.

Methods

Name Description
AddColumn Add a new column to the current table.
AddRow Add a new row to the current table.
GetClassType Get the type of this class.
GetRow Get the table row by its position in the table.
GetRowsCount Get the number of rows in the current table.
MergeCells Merge an array of cells. If the merge is done successfully it will return the resulting merged cell, otherwise the result will be "null".
RemoveColumn Remove the table column with a specified cell.
RemoveRow Remove the table row with a specified cell.
SetCellSpacing Specify the default table cell spacing (the spacing between adjacent cells and the edges of the table).
SetJc Specify the alignment of the current table with respect to the text margins in the current section.
SetShd Specify the shading which is applied to the extents of the current table.
SetStyle Set the style for the current table.
SetStyleColBandSize Specify the number of columns which will comprise each table column band for this table style.
SetStyleRowBandSize Specify the number of rows which will comprise each table row band for this table style.
SetTableBorderBottom Set the border which will be displayed at the bottom of the current table.
SetTableBorderInsideH Specify the border which will be displayed on all horizontal table cell borders which are not on an outmost edge of the parent table (all horizontal borders which are not the topmost or bottommost border).
SetTableBorderInsideV Specify the border which will be displayed on all vertical table cell borders which are not on an outmost edge of the parent table (all vertical borders which are not the leftmost or rightmost border).
SetTableBorderLeft Set the border which will be displayed on the left of the current table.
SetTableBorderRight Set the border which will be displayed on the right of the current table.
SetTableBorderTop Set the border which will be displayed at the top of the current table.
SetTableCellMarginBottom Specify the amount of space which will be left between the bottom extent of the cell contents and the border of all table cells within the parent table (or table row).
SetTableCellMarginLeft Specify the amount of space which will be present between the left extent of the cell contents and the left border of all table cells within the parent table (or table row).
SetTableCellMarginRight Specify the amount of space which will be present between the right extent of the cell contents and the right border of all table cells within the parent table (or table row).
SetTableCellMarginTop Specify the amount of space which will be present between the top extent of the cell contents and the top border of all table cells within the parent table (or table row).
SetTableInd Specify the indentation which will be added before the leading edge of the current table in the document (the left edge in a left-to-right table, and the right edge in a right-to-left table).
SetTableLayout Specify the algorithm which will be used to lay out the contents of this table within the document.
SetTableLook Specify the components of the conditional formatting of the referenced table style (if one exists) which will 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, for example, different formatting for first column, which then can be applied or omitted from individual table rows in the parent table.
SetWidth Set the preferred width for this table.

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oTable, oTableStyle, oCell;
oTableStyle = oDocument.CreateStyle("CustomTableStyle", "table");
oTableStyle.SetBasedOn(oDocument.GetStyle("Bordered - Accent 5"));
oTable = Api.CreateTable(5, 5);
oTable.SetWidth("percent", 100);
oTable.SetStyle(oTableStyle);
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);
builder.SaveFile("docx", "MergeCells.docx");
builder.CloseFile();

Resulting document