Skip to main content

SetTextPr

Applies the text settings to the entire contents of the current cell.

Syntax

expression.SetTextPr(oTextPr);

expression - A variable that represents a ApiTableCell class.

Parameters

NameRequired/OptionalData typeDefaultDescription
oTextPrRequiredApiTextPrThe properties that will be set to the current table cell text.

Returns

boolean

Example

Apply uniform text formatting to all content inside a table cell in a document.

// How do I change the font style and size of all text in a table cell in a document?

// Style every character in a table cell at once by setting shared text properties in a document.

let doc = Api.GetDocument();
let tableStyle = doc.CreateStyle("CustomTableStyle", "table");
tableStyle.SetBasedOn(doc.GetStyle("Bordered"));
let table = Api.CreateTable(3, 3);
table.SetWidth("percent", 100);
table.SetStyle(tableStyle);
table.GetCell(0, 0).GetContent().GetElement(0).AddText("Cell 1");
doc.Push(table);
let textPr = Api.CreateTextPr();
textPr.SetFontSize(30);
textPr.SetBold(true);
table.GetCell(0, 0).SetTextPr(textPr);