Get Started
Usage API
More information

ApiTableCell

new ApiTableCell()

Class representing a table cell.

Methods

Name Description
AddColumns

Adds the new columns to the current table.

AddElement

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

AddRows

Adds the new rows to the current table.

Clear

Clears the content from the current cell.

GetClassType

Returns a type of the ApiTableCell class.

GetContent

Returns the current cell content.

GetIndex

Returns the current cell index.

GetNext

Returns the next cell if exists.

GetParentRow

Returns a parent row of the current cell.

GetParentTable

Returns a parent table of the current cell.

GetPrevious

Returns the previous cell if exists.

GetRowIndex

Returns an index of the parent row.

RemoveColumn

Removes a column containing the current cell.

RemoveRow

Removes a row containing the current cell.

Search

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

SetBackgroundColor

Sets the background color to the current table cell.

SetCellBorderBottom

Sets the border which will be displayed at the bottom of the current table cell.

SetCellBorderLeft

Sets the border which will be displayed to the left of the current table cell.

SetCellBorderRight

Sets the border which will be displayed to the right of the current table cell.

SetCellBorderTop

Sets the border which will be displayed at the top of the current table cell.

SetCellMarginBottom

Specifies an amount of space which will be left between the bottom extent of the cell contents and the border of a specific table cell within a table.

SetCellMarginLeft

Specifies an amount of space which will be left between the left extent of the cell contents and the border of a specific table cell within a table.

SetCellMarginRight

Specifies an amount of space which will be left between the right extent of the cell contents and the border of a specific table cell within a table.

SetCellMarginTop

Specifies an amount of space which will be left between the upper extent of the cell contents and the border of a specific table cell within a table.

SetCellPr

Sets the cell properties to the current cell.

SetColumnBackgroundColor

Sets the background color to all cells in the column containing the current cell.

SetNoWrap

Specifies how the current table cell is laid out when the parent table is displayed in a document. This setting only affects the behavior of the cell when the ApiTablePr.SetTableLayout table layout for this table is set to use the "autofit" algorithm.

SetShd

Specifies the shading applied to the contents of the table cell.

SetTextDirection

Specifies the direction of the text flow for this table cell.

SetTextPr

Applies the text settings to the entire contents of the current cell.

SetVerticalAlign

Specifies the vertical alignment for the text contents within the current table cell.

SetWidth

Sets the preferred width to the current table cell.

Split

Splits the cell into a given number of rows and columns.

ToJSON

Converts the ApiTableCellPr object into the JSON object.

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(1, 1);
oTable.SetWidth("percent", 100);
var oCell = oTable.GetCell(0, 0);
oCell.AddColumns(2, false);
oCell.AddRows(2, false);
var oParentRow = oCell.GetParentRow();
oParentRow.SetHeight("atLeast", 1440);
var oParentTable = oCell.GetParentTable();
oParentTable.SetTableBorderBottom("single", 4, 0, 255, 0, 0);
oCell.SetVerticalAlign("top");
var oParagraph = oCell.GetContent().GetElement(0);
oParagraph.AddText("Align top");
oCell = oTable.GetRow(0).GetCell(1);
oCell.SetVerticalAlign("center");
oParagraph = oCell.GetContent().GetElement(0);
oParagraph.AddText("Align center");
oCell = oTable.GetRow(0).GetCell(2);
oCell.SetVerticalAlign("bottom");
oParagraph = oCell.GetContent().GetElement(0);
oParagraph.AddText("Align bottom");
oTable.SetStyle(oTableStyle);
var oNextCell = oTable.GetCell(0, 1).GetNext();
oNextCell.GetContent().GetElement(0).SetBold(true);
var oPreviousCell = oTable.GetCell(0, 1).GetPrevious();
oPreviousCell.GetContent().GetElement(0).SetBold(true);
oCell = oTable.GetRow(0).GetCell(0);
oCell.SetCellBorderBottom("single", 32, 0, 0, 0, 255);
oCell.SetCellBorderLeft("single", 32, 0, 0, 0, 255);
oCell.SetCellBorderRight("single", 32, 0, 0, 0, 255);
oCell.SetCellBorderTop("single", 32, 0, 0, 0, 255);
oTable.GetCell(1, 0).GetContent().GetElement(0).AddText("Cell index: " + oTable.GetCell(1, 0).GetIndex());
oDocument.Push(oTable);
var sClassType = oCell.GetClassType();
oParagraph = oDocument.GetElement(0);
oParagraph.AddText("Class Type = " + sClassType);
builder.SaveFile("docx", "ApiTableCell.docx");
builder.CloseFile();

Resulting document