SetTextPr
将文本设置应用于表格的全部内容。
语法
expression.SetTextPr(oTextPr);
expression - 表示 ApiTable 类的变量。
参数
| 名称 | 必需/可选 | 数据类型 | 默认值 | 描述 |
|---|---|---|---|---|
| oTextPr | 必需 | ApiTextPr | 将设置到当前表格的文本属性。 |
返回值
boolean
示例
在文档中为整个表格的每个单元格应用共享文本样式。
// How do I make all the text in a table bold and larger at once in a document?
// Uniform the font formatting throughout a table without editing each cell separately 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");
table.GetCell(0, 1).GetContent().GetElement(0).AddText("Cell 2");
table.GetCell(0, 2).GetContent().GetElement(0).AddText("Cell 3");
doc.Push(table);
let textPr = Api.CreateTextPr();
textPr.SetFontSize(30);
textPr.SetBold(true);
table.SetTextPr(textPr);