Get Started
Documentation

SetHAlign

SetHAlign(sType) → { bool }

Sets horizontal alignment for a table.

Parameters:

Name Type Description
sType String

may be "left" or "center" or "right"

Returns:

Type
bool

Example

Copy code
builder.CreateFile("docx");
oDocument = Api.GetDocument();
oTableStyle = oDocument.CreateStyle("CustomTableStyle", "table");
oTableStyle.SetBasedOn(oDocument.GetStyle("Bordered - Accent 5"));
oTable = Api.CreateTable(3, 3);
oTable.SetStyle(oTableStyle);
oDocument.Push(oTable);
oTable.GetCell(0, 0).GetContent().GetElement(0).AddText("This is just a sample text.");
oTable.SetHAlign("center");
builder.SaveFile("docx", "SetHAlign.docx");
builder.CloseFile();

Resulting document