Skip to main content

SetWidth

Sets the preferred width to the current table cell.

Syntax

expression.SetWidth(sType, nValue);

expression - A variable that represents a ApiTableCellPr class.

Parameters

NameRequired/OptionalData typeDefaultDescription
sTypeRequiredTableWidthType of the width value from one of the available width values types.
nValueOptionalnumberThe table cell width value measured in positive integers.

Returns

boolean

Example

Set a fixed minimum width for a table cell in a document.

// How do I control how wide a cell appears in a document?

// Enforce a consistent cell size across all columns in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("All cells are at least 2 inches wide:");
let tableStyle = doc.CreateStyle("CustomTableStyle", "table");
tableStyle.SetBasedOn(doc.GetStyle("Bordered"));
let table = Api.CreateTable(3, 3);
let tableCellPr = tableStyle.GetTableCellPr();
tableCellPr.SetWidth("twips", 2880);
table.SetStyle(tableStyle);
doc.Push(table);