跳到主要内容

GetColumnWidth

返回当前表格中指定列(按索引)的宽度。

语法​

expression.GetColumnWidth(columnIndex);

expression - 表示 ApiTable 类的变量。

参数​

名称必需/可选数据类型默认值描述
columnIndex必需number从零开始的列索引。

返回值​

EMU | null

示例​

获取文档中表格特定列的宽度。

// Read a column width value measured in English measure units.

// Create a table, set the first column width and read it back.

let doc = Api.GetDocument();
let table = Api.CreateTable(3, 3);
table.SetWidth("percent", 100);
doc.Push(table);
table.SetColumnWidth(0, Api.MillimetersToEmus(40));
let columnWidth = table.GetColumnWidth(0);
let paragraph = doc.GetElement(0);
paragraph.AddText("Column width: " + columnWidth);