apps-script-utils 2.1.1 Help

prependRow

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

prependRows with a single row: room is made first, so nothing already there is overwritten. A sheet gets the row at its top; a range gets it immediately above its first row, with the values written on the range's columns.

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

unknown

A single row: a flat array, one value per column.

options (optional) = {}

PrependRowsOptions \| null \| undefined

afterFrozenRows inserts below the frozen rows instead of at the very top. 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

no argument is passed.

InvalidSheetException

the first argument is neither a sheet nor a range.

TypeError

the values are not a flat array.

Examples

Inserting at the top of a sheet

const sheet = SpreadsheetApp.getActiveSheet(); prependRow(sheet, ["Name", "Email"]);

Inserting at a range

const sheet = SpreadsheetApp.getActiveSheet(); prependRow(sheet.getRange("B4:C13"), ["Name", "Email"]);

See also

Source

src/appsscript/sheet/prependRow.ts

23 September 2026

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