Get Started
Documentation

SetWidth

SetWidth(sType, nValueopt)

Set the preferred width for the current table cell.

Parameters:

Name Type Attributes Description
sType TableWidth Type of the width value from one of the available width values types.
nValue number <optional> The table cell width value measured in positive integers.

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph, oTable, oTableStyle, oCell, oTableCellPr;
oParagraph = oDocument.GetElement(0);
oParagraph.AddText("All cells are at least 2 inches wide:");
oTableStyle = oDocument.CreateStyle("CustomTableStyle", "table");
oTableStyle.SetBasedOn(oDocument.GetStyle("Bordered - Accent 5"));
oTable = Api.CreateTable(3, 3);
oTableCellPr = oTableStyle.GetTableCellPr();
oTableCellPr.SetWidth("twips", 2880);
oTable.SetStyle(oTableStyle);
oDocument.Push(oTable);
builder.SaveFile("docx", "SetWidth.docx");
builder.CloseFile();

Resulting document

The resulting sample document will be available here with the nearest ONLYOFFICE Document Builder API documentation website update.