apps-script-utils 2.1.1 Help

appendColumns

function appendColumns( target: GoogleAppsScript.Spreadsheet.Sheet | GoogleAppsScript.Spreadsheet.Range, values: unknown, options: Options | null | undefined = {} ): GoogleAppsScript.Spreadsheet.Sheet;

Pass a sheet and the whole sheet is examined; pass a range and only the cells inside it are, which is how data further down the sheet is kept from pushing the write to the right. A range also decides the rows written on — the sheet always starts at row 1.

The values are a matrix of rows: one array per row, all of the same length. Nothing is overwritten — the write starts one column past the last one holding data, and 0 and false count as data. The sheet gains columns when it is too narrow for the result.

A cell whose text starts with = is written as a formula, not as text — the same rule the editor follows.

A failure inside the write — the service unavailable, the sheet gone — comes back as the error the service raised, with its stack. The document lock is released either way.

Parameters

Parameter

Type

Description

target

GoogleAppsScript.Spreadsheet.Sheet \| GoogleAppsScript.Spreadsheet.Range

The sheet to append to, or the range to append within.

values

unknown

A matrix of rows: one array per row, all of the same length.

options (optional) = {}

Options \| null \| undefined

afterFrozenColumns starts the write past the frozen columns when the data ends before them.

Returns

GoogleAppsScript.Spreadsheet.Sheet — the sheet, so calls can be chained.

Throws

Exception

Condition

IllegalArgumentException

no argument is passed.

InvalidSheetException

the first argument is neither a sheet nor a range.

TypeError

the values are not a matrix with rows of equal length.

Examples

Appending to a sheet

const sheet = SpreadsheetApp.getActiveSheet(); appendColumns(sheet, [["total", "=SUM(A2:A)"]]);

Appending within a range

const sheet = SpreadsheetApp.getActiveSheet(); appendColumns(sheet.getRange("A1:D2"), [["a"], ["b"]]);

See also

Source

src/appsscript/sheet/appendColumns.ts

23 September 2026

This documentation was generated with AI (Claude) from the library's source code.