Pure builders for spreadsheets.batchUpdate requests. Each returns
one request Map; pass a Vec of them to
::google::sheets::spreadsheets/batch-update, which applies them
atomically in order.
Ranges are GridRanges with 0-based, end-exclusive indexes on a
numeric sheetId (not the title; see
::google::sheets::spreadsheets/sheet-id). Build one with
grid-range.
::req ::google::sheets::requests
header ::req/grid-range(0, 0, 1)
::google::sheets::spreadsheets/batch-update("1AbCspreadsheetId", [
::req/freeze(0, 1),
::req/bold(header),
::req/background(header, ::req/hex-color("#e8f0fe")),
::req/auto-resize(0, "COLUMNS")
])
Values
DIMENSIONS
DIMENSIONS: Vec [
"ROWS",
"COLUMNS"
]
Functions
add-sheet
fn (title: Str): Map
fn (title: Str, opts: Map): Map
addSheet: a new tab titled title. Options: index (position),
rowCount, columnCount, frozenRowCount, sheetId (choose the id),
hidden.
Example
::google::sheets::requests/add-sheet("Archive") // {addSheet: {properties: {title: "Archive"}}}
::google::sheets::requests/add-sheet("Archive", {index: 0, rowCount: 100}).addSheet.properties
// {title: "Archive", index: 0, gridProperties: {rowCount: 100}}
append-dimension
fn (sheet-id: Int, dim: Str, count: Int): Map
appendDimension: add count empty rows (or columns) at the end of a
sheet.
Example
::google::sheets::requests/append-dimension(0, "ROWS", 100)
// {appendDimension: {sheetId: 0, dimension: "ROWS", length: 100}}
auto-resize
fn (sheet-id: Int, dim: Str): Map
fn (sheet-id: Int, dim: Str, start: Int?, end: Int?): Map
autoResizeDimensions: fit "COLUMNS" (or "ROWS") to their content,
all of them or start to end (0-based, exclusive).
Example
::google::sheets::requests/auto-resize(0, "COLUMNS")
// {autoResizeDimensions: {dimensions: {sheetId: 0, dimension: "COLUMNS"}}}
::google::sheets::requests/auto-resize(0, "COLUMNS", 0, 3).autoResizeDimensions.dimensions.endIndex // 3
background
fn (range: Map, color: Map): Map
Fill range with color (from rgb or hex-color).
Example
::google::sheets::requests/background(::google::sheets::requests/grid-range(0, 0, 1), ::google::sheets::requests/hex-color("#e8f0fe")).repeatCell.fields // "userEnteredFormat.backgroundColor"
bold
fn (range: Map): Map
Make range bold (only textFormat.bold changes).
Example
::google::sheets::requests/bold(::google::sheets::requests/grid-range(0, 0, 1)).repeatCell.fields // "userEnteredFormat.textFormat.bold"
delete-dimension
fn (sheet-id: Int, dim: Str, start: Int, end: Int): Map
deleteDimension: delete rows (or columns) start to end.
Example
::google::sheets::requests/delete-dimension(0, "ROWS", 1, 3)
// {deleteDimension: {range: {sheetId: 0, dimension: "ROWS", startIndex: 1, endIndex: 3}}}
delete-sheet
fn (sheet-id: Int): Map
deleteSheet: remove a tab and its data.
Example
::google::sheets::requests/delete-sheet(7) // {deleteSheet: {sheetId: 7}}
dimension-range
fn (sheet-id: Int, dim: Str, start: Int?, end: Int?): Map
A DimensionRange: rows or columns start (inclusive) to end
(exclusive) of sheet-id; null bounds are open.
Example
::google::sheets::requests/dimension-range(0, "ROWS", 1, 5)
// {sheetId: 0, dimension: "ROWS", startIndex: 1, endIndex: 5}
duplicate-sheet
fn (sheet-id: Int, new-title: Str): Map
fn (sheet-id: Int, new-title: Str, opts: Map): Map
duplicateSheet: copy a tab within the spreadsheet as new-title
(inserted after the source unless opts.index).
Example
::google::sheets::requests/duplicate-sheet(0, "Copy", {index: 1})
// {duplicateSheet: {sourceSheetId: 0, newSheetName: "Copy", insertSheetIndex: 1}}
format-fields
fn (format: Map): Str
The fields mask for a userEnteredFormat Map (pure): {textFormat: {bold: true}, backgroundColor: ...} gives
"userEnteredFormat(textFormat,backgroundColor)", so other formatting
is left alone.
Example
::google::sheets::requests/format-fields({textFormat: {bold: true}}) // "userEnteredFormat(textFormat)"
freeze
fn (sheet-id: Int, rows: Int): Map
fn (sheet-id: Int, rows: Int?, columns: Int?): Map
updateSheetProperties freezing the first rows rows (and columns
columns when given). 0 unfreezes. Only the counts you pass are changed.
Example
::google::sheets::requests/freeze(0, 1).updateSheetProperties.fields // "gridProperties.frozenRowCount"
::google::sheets::requests/freeze(0, 1, 2).updateSheetProperties.properties.gridProperties
// {frozenRowCount: 1, frozenColumnCount: 2}
grid-range
fn (sheet-id: Int): Map
fn (sheet-id: Int, start-row: Int?, end-row: Int?): Map
fn (sheet-id: Int, start-row: Int?, end-row: Int?, start-column: Int?, end-column: Int?): Map
A GridRange on sheet-id (0-based, end exclusive; null leaves a side
unbounded): grid-range(0, 0, 1) is the first row; grid-range(0, 1, null, 2, 4) is columns C:D from row 2 down.
Example
::google::sheets::requests/grid-range(0) // {sheetId: 0}
::google::sheets::requests/grid-range(0, 0, 1) // {sheetId: 0, startRowIndex: 0, endRowIndex: 1}
::google::sheets::requests/grid-range(0, 1, null, 2, 4)
// {sheetId: 0, startRowIndex: 1, startColumnIndex: 2, endColumnIndex: 4}
header-row
fn (sheet-id: Int): Vec
fn (sheet-id: Int, color: Map?): Vec
The usual header treatment as a Vec of requests: freeze row 1 and make
it bold (and fill it with color when given).
Example
length(::google::sheets::requests/header-row(0)) // 2
length(::google::sheets::requests/header-row(0, ::google::sheets::requests/hex-color("#e8f0fe"))) // 3
hex-color
fn (hex: Str): Map
A Sheets Color from a hex string ("#1a73e8" or "1a73e8"); an Err for
anything else.
Example
::google::sheets::requests/hex-color("#ff0000") // {red: 1.0, green: 0.0, blue: 0.0}
is-err(::google::sheets::requests/hex-color("red")) // true
insert-dimension
fn (sheet-id: Int, dim: Str, start: Int, end: Int): Map
fn (sheet-id: Int, dim: Str, start: Int, end: Int, inherit-from-before: Bool): Map
insertDimension: insert empty rows (or columns) at start up to
end, inheriting formatting from the row before unless
inherit-from-before is false.
Example
::google::sheets::requests/insert-dimension(0, "ROWS", 1, 3).insertDimension.inheritFromBefore // true
// Row 0 has nothing before it to inherit from
::google::sheets::requests/insert-dimension(0, "ROWS", 0, 3).insertDimension.inheritFromBefore // false
number-format
fn (range: Map, format-type: Str): Map
fn (range: Map, format-type: Str, pattern: Str?): Map
Apply a number format: format-type is NUMBER, CURRENCY, PERCENT,
DATE, TIME, DATE_TIME, SCIENTIFIC or TEXT; pattern is
optional (e.g. "#,##0.00", "yyyy-mm-dd").
Example
::google::sheets::requests/number-format(::google::sheets::requests/grid-range(0, 1, null, 2, 3), "currency", "$#,##0.00").repeatCell.cell
// {userEnteredFormat: {numberFormat: {type: "CURRENCY", pattern: "$#,##0.00"}}}
rename-sheet
fn (sheet-id: Int, title: Str): Map
updateSheetProperties setting a tab's title.
Example
::google::sheets::requests/rename-sheet(0, "Archive").updateSheetProperties.fields // "title"
repeat-format
fn (range: Map, format: Map): Map
fn (range: Map, format: Map, fields: Str): Map
repeatCell applying format (a CellFormat: textFormat,
backgroundColor, horizontalAlignment, numberFormat,
wrapStrategy, ...) to every cell of range. Only the top-level format
fields you give are changed; pass fields to set the mask yourself.
Example
range ::google::sheets::requests/grid-range(0, 0, 1)
req ::google::sheets::requests/repeat-format(range, {horizontalAlignment: "CENTER"})
req.repeatCell.fields // "userEnteredFormat(horizontalAlignment)"
// Set the mask yourself
::google::sheets::requests/repeat-format(range, {textFormat: {italic: true}}, "userEnteredFormat.textFormat.italic").repeatCell.fields
// "userEnteredFormat.textFormat.italic"
rgb
fn (red: Int, green: Int, blue: Int): Map
A Sheets Color from 0-255 channels: rgb(26, 115, 232) is {red: 0.1019..., green: 0.4509..., blue: 0.9098...}.
Example
::google::sheets::requests/rgb(255, 0, 0) // {red: 1.0, green: 0.0, blue: 0.0}
set-size
fn (sheet-id: Int, dim: Str, start: Int, end: Int, pixels: Int): Map
updateDimensionProperties setting the pixel width of columns (or
height of rows) start to end.
Example
::google::sheets::requests/set-size(0, "COLUMNS", 0, 1, 240).updateDimensionProperties.properties // {pixelSize: 240}