SetTextPr
将文本设置应用于当前单元格的整个内容。
语法
expression.SetTextPr(oTextPr);
expression - 表示 ApiTableCell 类的变量。
参数
| 名称 | 必需/可选 | 数据类型 | 默认值 | 描述 |
|---|---|---|---|---|
| oTextPr | 必需 | ApiTextPr | 将设置到当前表格单元格文本的属性。 |
返回值
boolean
示例
在文档中为表格单元格内的所有内容应用统一的文本格式。
// 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);