Office

Spreadsheets

The 20 tools for spreadsheets. Before an agent first makes one, it reads guide topic sheets.

create_sheet

Add a spreadsheet to a space: a real Excel-style workbook (formulas, formats, charts, tables) that people edit live. Start it from tabs of rows, or from a file (an .xlsx, .xlsm, .xls, .xlsb, .ods, .csv or .tsv workbook, by public URL or base64) with everything in it. Shape it with the sheet_* tools and check it (check_sheet). Read guide topic "sheets" first.

Parameters

space_idstringrequired
titlestringrequired
tabsobject[]
Tabs in order. Defaults to one empty tab "Sheet1".
Show child attributes
namestringrequired
rows((string | number | boolean | null)[])[]
Rows of cell values. A string starting with "=" is a formula, e.g. "=SUM(B2:B9)".
fileobject
Start from this workbook instead of tabs (up to 25 MB).
Show child attributes
namestringrequired
The file name; its extension gives the format, e.g. "budget.xlsx"
urlstring
A public http(s) address of the file
base64string
Or the file itself, base64

sheet_execute_command

Run ANY spreadsheet engine command by id with JSON params — every ribbon/menu action is a command. Find ids and parameter docs with sheet_list_commands. Examples: {"command":"cell.set","params":{"cell":"B2","input":"=SUM(A1:A9)"}}; {"command":"home.bold","params":{"range":"A1:C1"}}; {"command":"sheet.insert"}; {"command":"data.removeDuplicates","params":{"range":"A1:C20"}}. Most commands act on the current selection when range is omitted. Programmatic calls never open dialogs: missing required params give an error. Acts on the spreadsheet item_id, on the tab named by tab (default: the first) unless the range names one ("'Q1 Budget'!B4:D9"). Everyone with the sheet open sees the change at once.

Parameters

item_idstringrequired
The spreadsheet (from create_sheet or get_space)
tabstring
The tab this call works on (default: the first). Commands without a range — charts, pictures, shapes, frozen panes, tab settings — act on this tab.
selectionstring
Cells to select on that tab for this call ("B2:D9"; several areas with commas, "A1:A9,C1:C9"). Commands that act on the selection — paste, fill, table and PivotTable commands, sort or filter without a range — act there.
commandstringrequired
Command id, e.g. "cell.set", "home.fillColor", "insert.chart"
paramsobject
Command parameters (see the params field of sheet_list_commands); omit or {} for defaults

sheet_list_commands

List spreadsheet engine commands: id, label, ribbon path, shortcut, a parameter description (params) and whether it can run right now. Use it to discover what sheet_execute_command can do (e.g. search "sort", "border", "chart", "sheet"). Acts on the spreadsheet item_id, on the tab named by tab (default: the first) unless the range names one ("'Q1 Budget'!B4:D9").

Parameters

item_idstringrequired
The spreadsheet (from create_sheet or get_space)
tabstring
The tab this call works on (default: the first). Commands without a range — charts, pictures, shapes, frozen panes, tab settings — act on this tab.
selectionstring
Cells to select on that tab for this call ("B2:D9"; several areas with commas, "A1:A9,C1:C9"). Commands that act on the selection — paste, fill, table and PivotTable commands, sort or filter without a range — act there.
searchstring
Case-insensitive substring matched against id, label and ribbon path

sheet_inspect_workbook

Summary of the active workbook: title, path, dirty flag, sheets (name, used range, cell count, tables, charts, merges, filters, freeze panes), defined names, current selection and active cell, calculation mode and undo/redo history. Acts on the spreadsheet item_id, on the tab named by tab (default: the first) unless the range names one ("'Q1 Budget'!B4:D9").

Parameters

item_idstringrequired
The spreadsheet (from create_sheet or get_space)
tabstring
The tab this call works on (default: the first). Commands without a range — charts, pictures, shapes, frozen panes, tab settings — act on this tab.
selectionstring
Cells to select on that tab for this call ("B2:D9"; several areas with commas, "A1:A9,C1:C9"). Commands that act on the selection — paste, fill, table and PivotTable commands, sort or filter without a range — act there.

sheet_read_range

Read cell values from a range as rows (2-D array). Numbers/booleans/strings are returned as JSON values, empty cells as null, errors as {"error":"#DIV/0!"}. Without range, reads the sheet's used range. formulas:true returns formula text ("=SUM(B2:B4)") for formula cells; formatted:true returns the displayed text ("$1,234.00", "12%"). Acts on the spreadsheet item_id, on the tab named by tab (default: the first) unless the range names one ("'Q1 Budget'!B4:D9").

Parameters

item_idstringrequired
The spreadsheet (from create_sheet or get_space)
tabstring
The tab this call works on (default: the first). Commands without a range — charts, pictures, shapes, frozen panes, tab settings — act on this tab.
selectionstring
Cells to select on that tab for this call ("B2:D9"; several areas with commas, "A1:A9,C1:C9"). Commands that act on the selection — paste, fill, table and PivotTable commands, sort or filter without a range — act there.
formattedboolean
Return display text with number formats applied
formulasboolean
Return formulas instead of computed values for formula cells
rangestring
A1-style range, e.g. "A1:D10", "B:B", "Sheet2!A1:C3"
sheetstring
Sheet name (default: the active sheet)

sheet_write_range

Write a 2-D array of values starting at the top-left cell of range (rows of cells). Numbers, booleans, null (clears) and strings are accepted; strings starting with = are formulas ("=SUM(B2:B4)"), other strings are parsed like typed input ("12%", "1/2/2024", "$5"). One undo step. Example: {"range":"A1","values":[["Item","Cost"],["Rent",1200]]}. Acts on the spreadsheet item_id, on the tab named by tab (default: the first) unless the range names one ("'Q1 Budget'!B4:D9"). Everyone with the sheet open sees the change at once.

Parameters

item_idstringrequired
The spreadsheet (from create_sheet or get_space)
tabstring
The tab this call works on (default: the first). Commands without a range — charts, pictures, shapes, frozen panes, tab settings — act on this tab.
selectionstring
Cells to select on that tab for this call ("B2:D9"; several areas with commas, "A1:A9,C1:C9"). Commands that act on the selection — paste, fill, table and PivotTable commands, sort or filter without a range — act there.
rangestringrequired
Top-left cell or range, e.g. "A1" or "Sheet2!B3"
values((string | number | boolean | null)[])[]required
Rows of cell values

sheet_set_cell

Enter one cell exactly as if typed: a number, text, or a formula starting with = ("=AVERAGE(B2:B9)"). Dependent cells recalculate. Returns the command result; use sheet_get_cell to read the computed value. Acts on the spreadsheet item_id, on the tab named by tab (default: the first) unless the range names one ("'Q1 Budget'!B4:D9"). Everyone with the sheet open sees the change at once.

Parameters

item_idstringrequired
The spreadsheet (from create_sheet or get_space)
tabstring
The tab this call works on (default: the first). Commands without a range — charts, pictures, shapes, frozen panes, tab settings — act on this tab.
selectionstring
Cells to select on that tab for this call ("B2:D9"; several areas with commas, "A1:A9,C1:C9"). Commands that act on the selection — paste, fill, table and PivotTable commands, sort or filter without a range — act there.
cellstringrequired
Cell, e.g. "B7" or "Sheet2!C3"
inputstring | number | booleanrequired
Typed input: number, text or =formula

sheet_get_cell

Details of one cell: computed value and type, formula, display text, raw input, spill range, style, merge, comment and hyperlink. Acts on the spreadsheet item_id, on the tab named by tab (default: the first) unless the range names one ("'Q1 Budget'!B4:D9").

Parameters

item_idstringrequired
The spreadsheet (from create_sheet or get_space)
tabstring
The tab this call works on (default: the first). Commands without a range — charts, pictures, shapes, frozen panes, tab settings — act on this tab.
selectionstring
Cells to select on that tab for this call ("B2:D9"; several areas with commas, "A1:A9,C1:C9"). Commands that act on the selection — paste, fill, table and PivotTable commands, sort or filter without a range — act there.
cellstringrequired
Cell, e.g. "B7" or "Sheet2!C3"

sheet_evaluate_formula

Evaluate a formula against the active sheet WITHOUT changing any cell, e.g. "=SUM(B2:B10)/COUNT(B2:B10)" or "=VLOOKUP("x",A:B,2,FALSE)". cell sets the formula's position for relative references and ROW()/COLUMN(). Use English function names and , between arguments; a formula that couldn't be entered in a cell is an error saying why. Acts on the spreadsheet item_id, on the tab named by tab (default: the first) unless the range names one ("'Q1 Budget'!B4:D9").

Parameters

item_idstringrequired
The spreadsheet (from create_sheet or get_space)
tabstring
The tab this call works on (default: the first). Commands without a range — charts, pictures, shapes, frozen panes, tab settings — act on this tab.
selectionstring
Cells to select on that tab for this call ("B2:D9"; several areas with commas, "A1:A9,C1:C9"). Commands that act on the selection — paste, fill, table and PivotTable commands, sort or filter without a range — act there.
cellstring
Evaluate as if in this cell (default: active cell)
formulastringrequired
Formula text, with or without the leading =

sheet_format_range

Apply several formats to a range in one call: bold, italic, underline, font name/size, font color, fill color, number format, horizontal alignment, wrap, borders. Colors are "#RRGGBB" (fontColor also "auto", fillColor also "none"). numberFormat is a name (General, Number, Currency, Accounting, Comma, Percentage, Short Date, Long Date, Time, Fraction, Scientific, Text) or a format code ("#,##0.00", "0%", "yyyy-mm-dd"). Each property runs one command; the result lists them. Acts on the spreadsheet item_id, on the tab named by tab (default: the first) unless the range names one ("'Q1 Budget'!B4:D9"). Everyone with the sheet open sees the change at once.

Parameters

item_idstringrequired
The spreadsheet (from create_sheet or get_space)
tabstring
The tab this call works on (default: the first). Commands without a range — charts, pictures, shapes, frozen panes, tab settings — act on this tab.
selectionstring
Cells to select on that tab for this call ("B2:D9"; several areas with commas, "A1:A9,C1:C9"). Commands that act on the selection — paste, fill, table and PivotTable commands, sort or filter without a range — act there.
boldboolean
Bold on/off
bordersstring | object
A border preset name, or {preset, style?, color?}
Show child attributes
colorstring
Border color "#RRGGBB"
presetstringrequired
Border preset One of bottom, top, left, right, none, all, outside, thickOutside, thickBottom, doubleBottom, topBottom, topThickBottom, topDoubleBottom, insideHorizontal, insideVertical, inside, diagonalDown, diagonalUp.
stylestring
thin|medium|thick|dashed|dotted|double|hair…
fillColorstring
Background color "#RRGGBB" or "none"
fontColorstring
Text color "#RRGGBB" or "auto"
fontNamestring
Font family, e.g. "Calibri"
fontSizenumber
Font size in points
horizontalAlignstring
Horizontal alignment One of left, center, right, justify.
italicboolean
Italic on/off
numberFormatstring
Number format name or code
rangestringrequired
A1-style range, e.g. "A1:D10", "B:B", "Sheet2!A1:C3"
underlineboolean
Single underline on/off
wrapTextboolean
Wrap text on/off

sheet_insert_chart

Insert a chart from a data range (first row/column used as series names and categories, like Excel). Returns the chart id. Acts on the spreadsheet item_id, on the tab named by tab (default: the first) unless the range names one ("'Q1 Budget'!B4:D9"). Everyone with the sheet open sees the change at once.

Parameters

item_idstringrequired
The spreadsheet (from create_sheet or get_space)
tabstring
The tab this call works on (default: the first). Commands without a range — charts, pictures, shapes, frozen panes, tab settings — act on this tab.
selectionstring
Cells to select on that tab for this call ("B2:D9"; several areas with commas, "A1:A9,C1:C9"). Commands that act on the selection — paste, fill, table and PivotTable commands, sort or filter without a range — act there.
atstring
Top-left anchor cell (default: right of the data)
rangestringrequired
Source data range including headers, e.g. "A1:C6"
subtypestring
Variant (optional) One of clustered, stacked, stacked100, markers.
titlestring
Chart title
typestringrequired
Chart type One of column, bar, line, pie, doughnut, area, scatter, bubble, radar, combo, histogram, waterfall, funnel, treemap, sunburst, boxWhisker, stock.

sheet_create_table

Format a range as an Excel table (structured references, banded rows, filter buttons). The first row is the header by default. Acts on the spreadsheet item_id, on the tab named by tab (default: the first) unless the range names one ("'Q1 Budget'!B4:D9"). Everyone with the sheet open sees the change at once.

Parameters

item_idstringrequired
The spreadsheet (from create_sheet or get_space)
tabstring
The tab this call works on (default: the first). Commands without a range — charts, pictures, shapes, frozen panes, tab settings — act on this tab.
selectionstring
Cells to select on that tab for this call ("B2:D9"; several areas with commas, "A1:A9,C1:C9"). Commands that act on the selection — paste, fill, table and PivotTable commands, sort or filter without a range — act there.
headerboolean
First row holds headers (default true)
namestring
Table name (default Table1, Table2…)
rangestringrequired
Range including the header row, e.g. "A1:D20"
stylestring
Table style, e.g. "TableStyleMedium2" (default), "TableStyleLight9"

sheet_sort_range

Sort a range by one or more columns. keys: [{"column":"B","order":"desc"}, …] or just ["B"]. Without range the current region around the selection is sorted; header detection follows Excel unless header is given. Acts on the spreadsheet item_id, on the tab named by tab (default: the first) unless the range names one ("'Q1 Budget'!B4:D9"). Everyone with the sheet open sees the change at once.

Parameters

item_idstringrequired
The spreadsheet (from create_sheet or get_space)
tabstring
The tab this call works on (default: the first). Commands without a range — charts, pictures, shapes, frozen panes, tab settings — act on this tab.
selectionstring
Cells to select on that tab for this call ("B2:D9"; several areas with commas, "A1:A9,C1:C9"). Commands that act on the selection — paste, fill, table and PivotTable commands, sort or filter without a range — act there.
headerboolean
The first row is a header (kept in place)
keys(string | object)[]required
Sort levels, most significant first
Show child attributes
columnstringrequired
Column letter, e.g. "B"
orderstring
Sort order One of asc, desc.
rangestring
A1-style range, e.g. "A1:D10", "B:B", "Sheet2!A1:C3"

sheet_filter

Filter rows by a column (turns on AutoFilter on the current region, or range, when needed). Give values (keep rows whose cell text is one of them), custom ({op:">", value:"10", op2?, value2?, and?}), top ({count, bottom?, percent?}), or clear:true to remove this column's filter. Acts on the spreadsheet item_id, on the tab named by tab (default: the first) unless the range names one ("'Q1 Budget'!B4:D9"). Everyone with the sheet open sees the change at once.

Parameters

item_idstringrequired
The spreadsheet (from create_sheet or get_space)
tabstring
The tab this call works on (default: the first). Commands without a range — charts, pictures, shapes, frozen panes, tab settings — act on this tab.
selectionstring
Cells to select on that tab for this call ("B2:D9"; several areas with commas, "A1:A9,C1:C9"). Commands that act on the selection — paste, fill, table and PivotTable commands, sort or filter without a range — act there.
blanksboolean
Also keep blank cells
clearboolean
Clear this column's filter
columnstringrequired
Column letter, e.g. "C"
customobject
Custom criteria: {op: "="|"<>"|">"|">="|"<"|"<="|"beginsWith"|"contains"…, value, op2?, value2?, and?: bool}
rangestring
Data range to filter (default: the current region of the selection)
topobject
Top/bottom N: {count, bottom?: bool, percent?: bool}
values(string | number | boolean)[]
Values to keep

sheet_list_functions

List worksheet functions: name, category, signature and description. Filter with search (name or description) or category. Acts on the spreadsheet item_id, on the tab named by tab (default: the first) unless the range names one ("'Q1 Budget'!B4:D9").

Parameters

item_idstringrequired
The spreadsheet (from create_sheet or get_space)
tabstring
The tab this call works on (default: the first). Commands without a range — charts, pictures, shapes, frozen panes, tab settings — act on this tab.
selectionstring
Cells to select on that tab for this call ("B2:D9"; several areas with commas, "A1:A9,C1:C9"). Commands that act on the selection — paste, fill, table and PivotTable commands, sort or filter without a range — act there.
categorystring
Category, e.g. "Math & Trig", "Lookup & Reference"
searchstring
Substring of the name or description

sheet_run_commands

Run several spreadsheet engine commands in order in one call (each as sheet_execute_command runs it), e.g. edit.copy then edit.pasteSpecial, or a block of formatting and structure. Nothing anyone else does lands in between. Stops at the first command that fails and says which; the ones before it stay done (sheet_undo takes back the whole run).

Parameters

item_idstringrequired
tabstring
Default tab for every command (default: the first)
commandsobject[]required
Show child attributes
commandstringrequired
A command id from sheet_list_commands, e.g. "home.mergeCells"
paramsobject
tabstring
This command's tab, if not the default
selectionstring
Cells to select for this command ("B2:D9")

sheet_undo

Take back your own latest change to the spreadsheet (one tool call, or one sheet_run_commands run); call again for the one before. Only while nobody has changed the sheet since: it never takes back a person's or another agent's work. Everyone with the sheet open sees it go back.

Parameters

item_idstringrequired

check_sheet

Check a workbook the way a careful reader would: formula errors (#DIV/0!, #REF!, …) with the formula behind them, numbers stored as text, numbers too wide for their column (####), text cut off by a filled cell beside it (measured with the fonts the sheet is drawn in), long tables without a frozen header, empty tabs. Run it before you hand a sheet over.

Parameters

item_idstringrequired

render_sheet

See a tab as people see it in Artifacts: a screenshot of the sheet drawn by the spreadsheet engine (values, formats, column widths, frozen panes, charts, pictures), scrolled so range is in view. Look after you change layout, colours or charts; check_sheet finds what a picture hides (formula errors, numbers stored as text).

Parameters

item_idstringrequired
tabstring
Default: the first tab
rangestring
A cell or range to bring into view, e.g. "H4:P24" for a chart there. Default A1.
widthinteger
Pixels, default 1400
heightinteger
Pixels, default 900

export_sheet

Links to download the spreadsheet as an Excel workbook (.xlsx) or one tab as CSV. Fetch them with your Artifacts key (Authorization: Bearer).

Parameters

item_idstringrequired