sheet() renders a live, editable spreadsheet with a formula bar (A1 | fx), zero-eval formula recalculation, instant row filtering, multi-tab workbooks, and formula-injection-safe CSV/JSON export. The exact same JSON schema renders in @aiui.page, zero-code YAML, Chat ``` `sheet ``` fences, and the Split Artifacts Canvas.
sheet()
A1 | fx
eval
@aiui.page
sheet
Double-click any cell below (for example B2 or C2) to edit a value or formula and watch the totals recalculate live.
B2
C2
<ComponentPreview title="Live Multi-Tab Formula Spreadsheet">
{
"type": "sheet",
"id": "q4-budget",
"title": "Q4 SaaS Operating Plan",
"tabs": [
"name": "Q4 Budget",
"grid": [
["Department", "Budget ($)", "Actual ($)", "Variance ($)", "Status"],
["Engineering", 140000, 132500, "=B2-C2", "=IF(D2>=0, \"Under\", \"Over\")"],
["Infrastructure", 48000, 51200, "=B3-C3", "=IF(D3>=0, \"Under\", \"Over\")"],
["Marketing", 62000, 58400, "=B4-C4", "=IF(D4>=0, \"Under\", \"Over\")"],
["Total", "=SUM(B2:B4)", "=SUM(C2:C4)", "=SUM(D2:D4)", "=IF(D5>=0, \"On Track\", \"Review\")"],
["Average", "=ROUND(AVERAGE(B2:B4), 0)", "=ROUND(AVERAGE(C2:C4), 0)", "=ROUND(AVERAGE(D2:D4), 0)", ""]
]
},
"name": "Headcount",
["Team", "Current", "Planned", "Open Roles"],
["Core Platform", 8, 10, "=C2-B2"],
["Applied AI", 6, 9, "=C3-B3"],
["Design & DX", 4, 5, "=C4-B4"],
["Total", "=SUM(B2:B4)", "=SUM(C2:C4)", "=SUM(D2:D4)"]
}
</ComponentPreview>
<Tabs>
<Tab title="Python (@aiui.page)">
</Tab>
<Tab title="YAML (app.yaml)">
<Tab title="Chat Fence (Agent Reply)">
{"id":"q4-budget","title":"Q4 Budget","tabs":[{"name":"Summary","grid":[["Item","Cost"],["Compute",4200],["Storage",1100],["Total","=SUM(B2:B3)"]]}]}
</Tabs>
| Function / Operator | Example | Notes |
|---|---|---|
| Arithmetic & comparisons | =B2-C2, =(B2+C2)*1.1, =D2>=0 | Safe recursive-descent parser (no eval or Function). |
=B2-C2
=(B2+C2)*1.1
=D2>=0
Function
| SUM, AVERAGE / AVG | =SUM(B2:B10), =AVERAGE(C2:C10) | Supports single cells, ranges (A1:C5), and lists. |
SUM
AVERAGE
AVG
=SUM(B2:B10)
=AVERAGE(C2:C10)
A1:C5
| MIN, MAX, COUNT, COUNTA | =MAX(B2:B10), =COUNT(B2:B10) | Numeric vs non-empty cell counts. |
MIN
MAX
COUNT
COUNTA
=MAX(B2:B10)
=COUNT(B2:B10)
| ROUND, ABS, IF | =ROUND(AVERAGE(B2:B4), 2), =IF(D2>=0, "OK", "Over") | Guards #CYCLE! and #DIV/0! automatically. |
ROUND
ABS
IF
=ROUND(AVERAGE(B2:B4), 2)
=IF(D2>=0, "OK", "Over")
#CYCLE!
#DIV/0!
| Parameter | Type | Description |
| title | str | Toolbar title and export filename stem. |
title
str
| tabs | list[dict] | Multi-tab workbook: [{"name": str, "grid": list[list], "values"?: list[list]}]. |
tabs
list[dict]
[{"name": str, "grid": list[list], "values"?: list[list]}]
| headers, rows | list | Shorthand for a single-tab spreadsheet when tabs is omitted. |
headers
rows
list
| id | str | Optional stable artifact ID for versioned updates in the Artifacts Canvas. |
id
| action | str | Optional page action name; displays a Save button that posts {action, id, title, tab, grid, values, tabs} to @aiui.register_page_action. |
action
{action, id, title, tab, grid, values, tabs}
@aiui.register_page_action
| save_label | str | Custom label for the Save button when action is set (default "Save"). |
save_label
"Save"
Pass action="save_sheet" to turn aiui.sheet() into an editable data editor (like st.data_editor) that persists changes to your @aiui.register_page_action handler:
action="save_sheet"
aiui.sheet()
st.data_editor