TRY NEW VERSION

Try now New API BETA

Try out the new view and capabilities of the API documentation

START

COLUMNS

COLUMNS(arg1) → { number | string | boolean }

Returns the number of columns in an array or reference.

Parameters:

Name Type Description
arg1 ApiRange

Is an array or array formula, or a reference to a range of cells for which you want the number of columns.

Returns:

Type
number | string | boolean

Example

Copy code
builder.CreateFile("xlsx");
var oWorksheet = Api.GetActiveSheet();
var oFunction = Api.GetWorksheetFunction();
var column1 = [13, 14, 15];
var column2 = [23, 24, 25];

for (var i = 0; i < column1.length; i++) {
    oWorksheet.GetRange("A" + (i + 1)).SetValue(column1[i]);
}
for (var j = 0; j < column2.length; j++) {
    oWorksheet.GetRange("B" + (j + 1)).SetValue(column2[j]);
}

var oRange = oWorksheet.GetRange("A1:B3");
oWorksheet.GetRange("B4").SetValue(oFunction.COLUMNS(oRange));
builder.SaveFile("xlsx", "COLUMNS.xlsx");
builder.CloseFile();

Resulting document