TRY NEW VERSION

Try now New API BETA

Try out the new view and capabilities of the API documentation

START

ApiTablePr

new ApiTablePr()

Class representing the table properties.

Methods

Name Description
GetClassType

Returns a type of the ApiTablePr class.

GetTableDescription

Returns the table description.

GetTableTitle

Returns the table title (caption).

SetCellSpacing

Specifies the default table cell spacing (the spacing between adjacent cells and the edges of the table).

SetJc

Specifies the alignment of the current table with respect to the text margins in the current section.

SetShd

Specifies the shading which is applied to the extents of the current table.

SetStyleColBandSize

Specifies a number of columns which will comprise each table column band for this table style.

SetStyleRowBandSize

Specifies a number of rows which will comprise each table row band for this table style.

SetTableBorderBottom

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

SetTableBorderInsideH

Specifies the border which will be displayed on all horizontal table cell borders which are not on the outmost edge of the parent table (all horizontal borders which are not the topmost or bottommost borders).

SetTableBorderInsideV

Specifies the border which will be displayed on all vertical table cell borders which are not on the outmost edge of the parent table (all vertical borders which are not the leftmost or rightmost borders).

SetTableBorderLeft

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

SetTableBorderRight

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

SetTableBorderTop

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

SetTableCellMarginBottom

Specifies an 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

Specifies an amount of space which will be left between the left extent of the cell contents and the left border of all table cells within the parent table (or table row).

SetTableCellMarginRight

Specifies an amount of space which will be left between the right extent of the cell contents and the right border of all table cells within the parent table (or table row).

SetTableCellMarginTop

Specifies an amount of space which will be left between the top extent of the cell contents and the top border of all table cells within the parent table (or table row).

SetTableDescription

Sets the table description.

SetTableInd

Specifies the indentation which will be added before the leading edge of the current table in the document (the left edge in the left-to-right table, and the right edge in the right-to-left table).

SetTableLayout

Specifies the algorithm which will be used to lay out the contents of the current table within the document.

SetTableTitle

Sets the table title (caption).

SetWidth

Sets the preferred width to the current table. Tables are created with the ApiTable#SetWidth method properties set by default, which always override the ApiTablePr#SetWidth method properties. That is why there is no use to try and apply ApiTablePr#SetWidth. We recommend you to use the ApiTablePr#SetWidth method instead.

ToJSON

Converts the ApiTablePr 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"));
var oTablePr = oTableStyle.GetTablePr();
oTablePr.SetJc("center");
oTablePr.SetCellSpacing(720);
oTablePr.SetTableBorderBottom("single", 32, 0, 51, 51, 51);
oTablePr.SetTableBorderLeft("single", 32, 0, 51, 51, 51);
oTablePr.SetTableBorderRight("single", 32, 0, 51, 51, 51);
oTablePr.SetTableBorderTop("single", 32, 0, 51, 51, 51);
oTablePr.SetWidth("percent", 100);
var oTable = Api.CreateTable(4, 2);
oTable.SetTableLook(true, true, true, true, true, true);
oTablePr.SetStyleColBandSize(2);
oTableStyle.GetConditionalTableStyle("bandedColumn").GetTextPr().SetBold(true);
oTable.GetRow(0).GetCell(0).GetContent().GetElement(0).AddText("Bold");
oTable.GetRow(0).GetCell(1).GetContent().GetElement(0).AddText("Bold");
oTable.GetRow(0).GetCell(2).GetContent().GetElement(0).AddText("Normal");
oTable.GetRow(0).GetCell(3).GetContent().GetElement(0).AddText("Normal");
oTable.GetRow(1).GetCell(0).GetContent().GetElement(0).AddText("Bold");
oTable.GetRow(1).GetCell(1).GetContent().GetElement(0).AddText("Bold");
oTable.GetRow(1).GetCell(2).GetContent().GetElement(0).AddText("Normal");
oTable.GetRow(1).GetCell(3).GetContent().GetElement(0).AddText("Normal");
oTable.SetStyle(oTableStyle);
var sClassType = oTablePr.GetClassType();
var oParagraph = oDocument.GetElement(0);
oParagraph.AddText("Class Type = " + sClassType);
oDocument.Push(oTable);
builder.SaveFile("docx", "ApiTablePr.docx");
builder.CloseFile();

Resulting document