跳到主要内容

GetCols

返回表示指定范围中的列的 Range 对象。

语法

expression.GetCols(nCol);

expression - 表示 ApiRange 类的变量。

参数

名称必需/可选数据类型默认值描述
nCol必需number列号。*

返回值

ApiRange | null

示例

从电子表格中的范围提取一组列作为其自己的子范围。

// How do I select only the first few columns of a range in a spreadsheet?

// Isolate the leading columns from a wider selection and fill them with a highlight color.

let worksheet = Api.GetActiveSheet();
let range = worksheet.GetRange("A1:C3");
range.GetCols(2).SetFillColor(Api.CreateColorFromRGB(255, 213, 191));