GetColumnWidth
返回当前表格中指定列(按索引)的宽度。
语法
expression.GetColumnWidth(columnIndex);
expression - 表示 ApiTable 类的变量。
参数
| 名称 | 必需/可选 | 数据类型 | 默认值 | 描述 |
|---|---|---|---|---|
| columnIndex | 必需 | number | 从零开始的列索引。 |
返回值
EMU | null
示例
测量 PDF 中表格列的宽度。
// Find out how wide a table column is in a PDF.
// Read the column width value and display it in a PDF.
const doc = Api.GetDocument();
const page = doc.GetPage(0);
const table = Api.CreateTable(3, 3);
table.SetColumnWidth(0, Api.MillimetersToEmus(100));
const width = table.GetColumnWidth(0);
const row = table.GetRow(0);
const cell = row.GetCell(0);
const content = cell.GetContent();
const paragraph = Api.CreateParagraph();
paragraph.AddText('Column 0 width: ' + width + ' EMU');
content.Push(paragraph);
page.AddObject(table);