apps-script-utils 2.1.1 Help

insertSchema

function insertSchema( sheet: GoogleAppsScript.Spreadsheet.Sheet, schema: SheetSchema ): GoogleAppsScript.Spreadsheet.Sheet;

The schema is written into the sheet's developer metadata, so it travels with the sheet — a copy of the spreadsheet carries it, and getSchema finds it again without reading a single cell.

The description is also put into effect: the header row is written and the columns get the formatting and the validation their types imply.

Parameters

Parameter

Type

Description

sheet

GoogleAppsScript.Spreadsheet.Sheet

The sheet to work on.

schema

SheetSchema

The schema: its version, the headerRow and the columns.

Returns

GoogleAppsScript.Spreadsheet.Sheet — the same sheet.

Throws

Exception

Condition

InvalidSheetException

the first argument is not a sheet.

Examples

Declaring a schema

const sheet = SpreadsheetApp.getActiveSheet(); insertSchema(sheet, { version: 1, headerRow: 1, columns: [ { name: "id", type: "number" }, { name: "email", type: "string" } ] });

See also

Source

src/appsscript/sheet/insertSchema.ts

23 September 2026

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