apps-script-utils 2.1.1 Help

prependColumn

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

prependColumns with a single column: room is made first, so nothing already there is overwritten. A sheet gets the column at its start; a range gets it immediately before its first column, with the values written on the range's rows.

The values go in as a flat array of cells, top to bottom. Omit them and an empty column is inserted.

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

Parameters

Parameter

Type

Description

target

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

The sheet to insert into, or the range to insert at.

values (optional)

unknown[] \| null

The cells of the single column, top to bottom. Omit for an empty column.

options (optional) = {}

Options \| null \| undefined

afterFrozenColumns inserts after the frozen columns instead of at the very start. A range decides the position itself, so the option does nothing there.

Returns

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

Throws

Exception

Condition

IllegalArgumentException

the values are given but are not a non-empty flat array.

InvalidSheetException

the first argument is neither a sheet nor a range.

Examples

Inserting at the start of a sheet

const sheet = SpreadsheetApp.getActiveSheet(); prependColumn(sheet, ["Name", "Ada", "Grace"]);

Inserting at a range

const sheet = SpreadsheetApp.getActiveSheet(); prependColumn(sheet.getRange("C4:F13"), ["Name", "Ada"]);

See also

Source

src/appsscript/sheet/prependColumn.ts

23 September 2026

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