Get Started
Documentation

ApiTableCell

new ApiTableCell()

Class representing a table cell.

Extends

Name Description
ApiTableCellPr Class representing table cell properties.

Methods

Name Description
GetClassType Get the type of this class.
GetContent Get the cell content.
SetCellBorderBottom Set the border which will be displayed at the bottom of the current table cell.
SetCellBorderLeft Set the border which will be displayed to the left of the current table cell.
SetCellBorderRight Set the border which will be displayed to the right of the current table cell.
SetCellBorderTop Set the border which will be displayed at the top of the current table cell.
SetCellMarginBottom Specify the 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 Specify the 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 Specify the 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 Specify the 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.
SetNoWrap Specify how this 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 SetTableLayout table layout for this table is set to use the "autofit" algorithm.
SetShd Specify the shading applied to the contents of the table cell.
SetTextDirection Specify the direction of the text flow for this table cell.
SetVerticalAlign Specify the vertical alignment for text contents within the current table cell.
SetWidth Set the preferred width for the current table cell.

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph, oTable, oTableStyle, oCell, oTableRow;
oTableStyle = oDocument.CreateStyle("CustomTableStyle", "table");
oTableStyle.SetBasedOn(oDocument.GetStyle("Bordered - Accent 5"));
oTable = Api.CreateTable(3, 3);
oTable.SetWidth("percent", 100);
oTableRow = oTable.GetRow(0);
oTableRow.SetHeight("atLeast", 1440);
oCell = oTable.GetRow(0).GetCell(0);
oCell.SetVerticalAlign("top");
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);
oDocument.Push(oTable);
builder.SaveFile("docx", "SetVerticalAlign.docx");
builder.CloseFile();

Resulting document