Get Started
Usage API
More information

ApiTableRow

new ApiTableRow()

Class representing a table row.

Methods

Name Description
AddRows

Adds the new rows to the current table.

Clear

Clears the content from the current row.

GetCell

Returns a cell by its position.

GetCellsCount

Returns a number of cells in the current row.

GetClassType

Returns a type of the ApiTableRow class.

GetIndex

Returns the current row index.

GetNext

Returns the next row if exists.

GetParentTable

Returns the parent table of the current row.

GetPrevious

Returns the previous row if exists.

MergeCells

Merges the cells in the current row.

Remove

Removes the current table row.

Search

Searches for a scope of a table row object. The search results are a collection of ApiRange objects.

SetBackgroundColor

Sets the background color to all cells in the current table row.

SetHeight

Sets the height to the current table row within the current table.

SetTableHeader

Specifies that the current table row will be repeated at the top of each new page wherever this table is displayed. This gives this table row the behavior of a 'header' row on each of these pages. This element can be applied to any number of rows at the top of the table structure in order to generate multi-row table headers.

SetTextPr

Sets the text properties to the current row.

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oTableStyle = oDocument.CreateStyle("CustomTableStyle", "table");
oTableStyle.SetBasedOn(oDocument.GetStyle("Bordered - Accent 5"));
var oTable = Api.CreateTable(3, 3);
oTable.SetWidth("percent", 100);
var oTableRow = oTable.GetRow(0);
oTableRow.SetHeight("atLeast", 720);
oTableRow.AddRows(1, true);
oTableRow = oTable.GetRow(0);
var oCell = oTableRow.GetCell(1);
oCell.SetVerticalAlign("bottom");
var oParagraph = oCell.GetContent().GetElement(0);
oParagraph.AddText("Align bottom");
var nCellsCount = oTableRow.GetCellsCount();
oTableRow.GetCell(0).GetContent().GetElement(0).AddText("Row index: " + oTableRow.GetIndex());
oTableRow = oTable.GetRow(1);
oTableRow.GetCell(0).GetContent().GetElement(0).AddText("Second row");
oTableRow.GetNext().GetCell(0).GetContent().GetElement(0).AddText("Third row");
oTableRow.GetPrevious().GetCell(1).GetContent().GetElement(0).SetBold(true);
oTableRow = oTable.GetRow(2);
oTableRow.MergeCells();
oTable.SetStyle(oTableStyle);
oDocument.Push(oTable);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Number of cells in the first row = " + nCellsCount);
var sClassType = oTableRow.GetClassType();
oParagraph.AddLineBreak();
oParagraph.AddText("Class Type = " + sClassType);
oDocument.Push(oParagraph);
builder.SaveFile("docx", "ApiTableRow.docx");
builder.CloseFile();

Resulting document