Skip to main content

SetNoWrap

Specifies how the current table cell is laid out when the parent table is displayed in a document.

This setting only affects the behavior of the cell when the ApiTablePr#SetTableLayout table layout for this table is set to use the "autofit" algorithm.

Inherited from ApiTableCellPr.SetNoWrap.

Syntax​

expression.SetNoWrap(isNoWrap);

expression - A variable that represents an ApiTableCell class.

Parameters​

NameRequired/OptionalData typeDefaultDescription
isNoWrapRequiredbooleanThe true value means that the current table cell will not be wrapped in the parent table.

Returns​

boolean

Example​

Prevent text from wrapping inside a table cell in a document.

// How do I stop text from breaking onto a new line inside a table cell in a document?

// Keep all text on a single line within a table cell regardless of column width in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let tableStyle = doc.CreateStyle("CustomTableStyle", "table");
tableStyle.SetBasedOn(doc.GetStyle("Bordered"));
let tablePr = tableStyle.GetTablePr();
let table = Api.CreateTable(3, 3);
tablePr.SetTableLayout("autofit");
table.SetTableLook(true, true, true, true, false, false);
table.SetStyle(tableStyle);
let cell = table.GetRow(0).GetCell(0);
cell.GetContent().GetElement(0).AddText("This is a table with the autofit type of the table layout.");
doc.Push(table);
let copyTable1 = table.Copy();
copyTable1.SetWidth("percent", 10);
cell = copyTable1.GetRow(0).GetCell(0);
cell.Clear();
cell.GetContent().GetElement(0).AddText("This is a table cell where text is wrapped when we try to change table width.");
cell.SetNoWrap(false);
doc.Push(copyTable1);
let copyTable2 = table.Copy();
copyTable2.SetWidth("percent", 10);
cell = copyTable2.GetRow(0).GetCell(0);
cell.Clear();
cell.GetContent().GetElement(0).AddText("This is a table cell where text is not wrapped when we try to change table width.");
cell.SetNoWrap(true);
doc.Push(copyTable2);