Overview
Thectx.sheet() and ctx.thisSheet APIs allow you to interact with sheets in your workbook. You can add rows, query data by value, and work across multiple sheets to build complex data pipelines.
Methods
ctx.sheet()
Get a reference to any sheet in your workbook by name.sheetName- The name of the sheet to access
Sheet object with methods for interacting with that sheet
Example:
ctx.thisSheet
A convenience reference to the current sheet. Equivalent toctx.sheet(currentSheetName).
Sheet Methods
addRow()
Add a new row to the sheet, or update an existing row if a unique column match is found.data- An object mapping column names to valuesoptions.create- Iftrue, create columns that don’t exist (default:false)
Row object representing the created or updated row
Behavior:
- If a unique column exists and matches, the existing row will be updated
- If no match is found, a new row is created
- The returned
Rowobject haswasCreatedorwasUpdatedproperties to indicate what happened
Creating Columns Dynamically
getRowsByValue()
Find all rows in the sheet where a specific column matches a value.columnName- The name of the column to searchvalue- The value to match
Row objects that match the criteria
Example:
Common Patterns
Push Data to Another Sheet
Process Array Data Across Sheets
Deduplicate and Merge Data
Aggregate Data from Multiple Sheets
Batch Operations
Row Object Reference
EachRow object returned by sheet methods has:
Properties
row.id- UUID of the rowrow.index- Numeric index (0-based)row.wasCreated- Boolean, true if newly createdrow.wasUpdated- Boolean, true if updated
Methods
row.get(columnName)- Get a valuerow.set(values)- Set one or more valuesrow.run(options?)- Trigger formula execution