跳到主要内容

SetTextPr

将文本设置应用于当前单元格的整个内容。

语法

expression.SetTextPr(oTextPr);

expression - 表示 ApiTableCell 类的变量。

参数

名称必需/可选数据类型默认值描述
oTextPr必需ApiTextPr将设置到当前表格单元格文本的属性。

返回值

boolean

示例

此示例将文本设置应用于单元格的整个内容。

// Set text properties to the table cell.

// Make the table cell bold and with bigger font.

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);