SetWidth
function SetWidth(sType: any = null, nValue: any = null): void
Description
Sets the preferred width to the current table. Tables are created with the {@link ApiTable#SetWidth} method properties set by default, which always override the {@link ApiTablePr#SetWidth} method properties. That is why there is no use to try and apply {@link ApiTablePr#SetWidth}. We recommend you to use the {@link ApiTablePr#SetWidth} method instead.
Parameters
- sType
any
null Type of the width value from one of the available width values types.
- nValue
any
null The table width value measured in positive integers.
Returns
void
Try It
var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
oParagraph.AddText("We set the table cells to preserve their size:");
var oTableStyle = oDocument.CreateStyle("CustomTableStyle", "table");
oTableStyle.SetBasedOn(oDocument.GetStyle("Bordered"));
var oTablePr = oTableStyle.GetTablePr();
var oTable = Api.CreateTable(3, 3);
oTablePr.SetWidth("percent", 100);
oTable.SetStyle(oTableStyle);
oDocument.Push(oTable);