Spreadsheets: metadata (with ranges, grid data and field masks), creation with a title and tabs, batchUpdate, and helpers for the common tab operations (list, find, add, rename, delete, duplicate, freeze, auto-resize, header formatting).

Scopes. get-spreadsheet, list-sheets and sheet-id use spreadsheets.readonly; everything else spreadsheets. drive.file works for spreadsheets the app created or the user opened with it. Deleting a whole spreadsheet is a Drive call (google-drive's trash-file / delete-file).

Values

SHEET_FIELDS

SHEET_FIELDS: Str "sheets.properties"

Functions

add-sheet

fn (spreadsheet-id: Str, title: Str): Map
fn (spreadsheet-id: Str, title: Str, opts: Map): Map

Add a tab and return its properties (with the new sheetId). Options as for ::google::sheets::requests/add-sheet. Scope: spreadsheets.

auto-resize-columns

fn (spreadsheet-id: Str, sheet-id: Int): Map
fn (spreadsheet-id: Str, sheet-id: Int, start: Int?, end: Int?): Map
fn (spreadsheet-id: Str, sheet-id: Int, start: Int?, end: Int?, opts: Map): Map

Fit every column of a tab (or start to end, 0-based exclusive) to its content. Scope: spreadsheets.

batch-update

fn (spreadsheet-id: Str, requests: Vec): Map
fn (spreadsheet-id: Str, requests: Vec, opts: Map): Map

POST /{id}:batchUpdate - apply structural and formatting requests atomically, in order (build them with ::google::sheets::requests). Returns {spreadsheetId, replies}, one reply per request (empty for most; addSheet replies carry the new sheet's properties). If any request fails, none is applied. Scope: spreadsheets.

batch-update-body

fn (requests: Vec, opts: Map): Map

The batchUpdate body (pure): {requests} plus includeSpreadsheetInResponse, responseRanges and responseIncludeGridData from opts when set.

build-spreadsheet

fn (title: Str, opts: Map): Map

The spreadsheets.create body (pure): {properties: {title, locale?, timeZone?}, sheets?}. opts.sheets is a Vec of tab titles or SheetProperties Maps; opts.locale (e.g. "en_US") and opts.timeZone (e.g. "America/Chicago") set the spreadsheet's defaults.

create-spreadsheet

fn (title: Str): Map
fn (title: Str, opts: Map): Map

POST /v4/spreadsheets - create a spreadsheet. Returns the resource with spreadsheetId and spreadsheetUrl. It lands in the authenticated user's My Drive root (move it with google-drive's move-file); a service account without domain-wide delegation owns it alone, so share it before anyone else can open it. Scope: spreadsheets (or drive.file).

book ::google::sheets::spreadsheets/create-spreadsheet("Q3 pipeline", {sheets: ["Leads", "Summary"], timeZone: "America/New_York"})
book.spreadsheetId

delete-sheet

fn (spreadsheet-id: Str, sheet-id: Int): Map
fn (spreadsheet-id: Str, sheet-id: Int, opts: Map): Map

Delete the tab sheet-id and its data (a spreadsheet must keep at least one tab). Scope: spreadsheets.

duplicate-sheet

fn (spreadsheet-id: Str, sheet-id: Int, new-title: Str): Map
fn (spreadsheet-id: Str, sheet-id: Int, new-title: Str, opts: Map): Map

Copy the tab sheet-id as new-title and return the copy's properties. Scope: spreadsheets.

find-sheet

fn (spreadsheet-id: Str, title: Str): Map?
fn (spreadsheet-id: Str, title: Str, opts: Map): Map?

The properties of the tab titled title (exact match), or null. Scope: spreadsheets.readonly.

format-header

fn (spreadsheet-id: Str, sheet-id: Int): Map
fn (spreadsheet-id: Str, sheet-id: Int, opts: Map): Map

Freeze and bold the first row of a tab, then fit its columns. Scope: spreadsheets.

freeze-rows

fn (spreadsheet-id: Str, sheet-id: Int, rows: Int): Map
fn (spreadsheet-id: Str, sheet-id: Int, rows: Int, opts: Map): Map

Freeze the first rows rows of a tab (0 unfreezes). Scope: spreadsheets.

get-params

fn (opts: Map): Map

The query parameters get-spreadsheet sends (pure): ranges (a Vec, sent repeated), includeGridData, fields (e.g. "properties.title,sheets.properties"), excludeTablesInBandedRanges; only the ones you set.

get-spreadsheet

fn (spreadsheet-id: Str): Map
fn (spreadsheet-id: Str, opts: Map): Map

GET /{id} - spreadsheet metadata: properties (title, locale, timeZone), sheets (each with properties: sheetId, title, index, gridProperties), namedRanges, spreadsheetUrl. Pass {ranges: ["Sheet1!A1:C5"], includeGridData: true} for cell data and formatting, and fields to trim the response. Scope: spreadsheets.readonly.

list-sheets

fn (spreadsheet-id: Str): Vec
fn (spreadsheet-id: Str, opts: Map): Vec

Every tab's properties (sheetId, title, index, sheetType, gridProperties), in order. Scope: spreadsheets.readonly.

rename-sheet

fn (spreadsheet-id: Str, sheet-id: Int, title: Str): Map
fn (spreadsheet-id: Str, sheet-id: Int, title: Str, opts: Map): Map

Rename the tab sheet-id. Scope: spreadsheets.

sheet-id

fn (spreadsheet-id: Str, title: Str): Int
fn (spreadsheet-id: Str, title: Str, opts: Map): Int

The numeric sheetId of the tab titled title (what ::google::sheets::requests builders take), or an Err when there is no such tab. Scope: spreadsheets.readonly.

sheet-properties

fn (sheet: Any): Map