跳到主要内容

SetWidth

设置当前表格单元格的首选宽度。

语法

expression.SetWidth(sType, nValue);

expression - 表示 ApiTableCellPr 类的变量。

参数

名称必需/可选数据类型默认值描述
sType必需TableWidth宽度值类型,来自可用的宽度值类型之一。
nValue可选number表格单元格宽度值,以正整数表示。

返回值

boolean

示例

此示例设置当前表格单元格的首选宽度。

// Resize the width of the cell.

// Change the width of the cell.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("All cells are at least 2 inches wide:");
let tableStyle = doc.CreateStyle("CustomTableStyle", "table");
tableStyle.SetBasedOn(doc.GetStyle("Bordered"));
let table = Api.CreateTable(3, 3);
let tableCellPr = tableStyle.GetTableCellPr();
tableCellPr.SetWidth("twips", 2880);
table.SetStyle(tableStyle);
doc.Push(table);