跳到主要内容

SetTableLayout

指定将用于在文档中布局当前表格内容的算法。

语法

expression.SetTableLayout(sType);

expression - 表示 ApiTable 类的变量。

参数

名称必需/可选数据类型默认值描述
sType必需"autofit" | "fixed"文档中表格布局的类型。

返回值

boolean

示例

此示例指定将用于在文档中布局表格内容的算法。

// How to set the table layout.

// Create a table and make its layout fixed.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("We set the table cells to preserve their size:");
let tableStyle = doc.CreateStyle("CustomTableStyle", "table");
tableStyle.SetBasedOn(doc.GetStyle("Bordered"));
let tablePr = tableStyle.GetTablePr();
let table = Api.CreateTable(3, 3);
tablePr.SetTableLayout("fixed");
table.SetTableLook(true, true, true, true, false, false);
table.SetStyle(tableStyle);
let cell = table.GetRow(0).GetCell(0);
cell.GetContent().GetElement(0).AddText("Fixed layout");
doc.Push(table);