跳到主要内容

SetTableTitle

设置表格标题(题注)。

语法

expression.SetTableTitle(sTitle);

expression - 表示 ApiTablePr 类的变量。

参数

名称必需/可选数据类型默认值描述
sTitle必需string要设置的表格标题。

返回值

boolean

示例

此示例设置表格标题。

// How to rename the table title.

// Create a table and indicate its title.

let doc = Api.GetDocument();
let tableStyle = doc.CreateStyle("CustomTableStyle", "table");
tableStyle.SetBasedOn(doc.GetStyle("Bordered"));
let tablePr = tableStyle.GetTablePr();
let table = Api.CreateTable(3, 3);
table.SetWidth("percent", 100);
tablePr.SetTableTitle("Table 1");
table.SetStyle(tableStyle);
let paragraph = doc.GetElement(0);
paragraph.AddText("Table title: " + tablePr.GetTableTitle());
doc.Push(table);