Overview
The spreadsheet automation tools provide comprehensive functionality for working with UniverJS-based spreadsheets (Univer Sheets). These tools enable cell manipulation, formula creation, data insertion, visualization with charts, and analysis with pivot tables. All tools execute client-side through theuniverAgentBridge, ensuring responsive spreadsheet interactions.
Key Characteristics
- Client-Side Execution: Tools return UI actions that execute in the browser
- Excel-Compatible: Supports standard Excel formulas and operations
- Data Integration: Direct database query integration with one-step data insertion
- Regulatory Compliance: ASIC RG94-compliant analysis and validation
- Comprehensive Visualization: Multiple chart types and pivot table support
P0 Critical Tools
These four tools are used in 50-80% of spreadsheet workflows and should be prioritized:1. prepare_spreadsheet_workspace
Type:async (purpose: str, suggestedWorkbookName?: str, autoInitialize?: bool) -> dict
Purpose: Initialize a spreadsheet workspace for data operations.
Description:
Prepares an Excel-like spreadsheet workspace by creating a new workbook, navigating to it, and selecting cell A1. Use this as the first step before any spreadsheet operations. Automatically handles workbook creation if none is loaded.
Parameters:
purpose(string, required): Why this workspace is being created (e.g., “add portfolio data”, “create NAV reconciliation”)suggestedWorkbookName(string, optional): Suggested name for the workbook. Defaults to ” Workbook”autoInitialize(boolean, optional): Automatically create and navigate to workbook. Default:true
- Starting any spreadsheet workflow
- Before calling
insert_data_to_spreadsheet - When user asks to “add data to a spreadsheet”
2. fetch_and_insert_to_spreadsheet
Type:async (query: str, explanation: str, includeHeaders?: bool, startRow?: int, startCol?: int) -> dict
Purpose: Atomic operation combining database fetch and spreadsheet insertion.
Description:
Executes a SQL query and inserts the results directly into the active spreadsheet in a single operation. This is the preferred approach for adding database data to spreadsheets as it’s more reliable than separate fetch/insert operations. Automatically formats headers when includeHeaders=true.
Parameters:
query(string, required): SQL query usingschema.tableformat (e.g.,SELECT * FROM investment.portfolios)explanation(string, required): Description of what the query does and whyincludeHeaders(boolean, optional): Add column headers in first row. Default:truestartRow(integer, optional): Starting row index (0-based). Default:0startCol(integer, optional): Starting column index (0-based). Default:0
- Database query must use
schema.tableformat - Query must be valid SQL
- User must have read permissions on the queried table
prepare_spreadsheet_workspace- Initialize workspace firstinsert_data_to_spreadsheet- Manual data insertionfetch_and_display- Universal fetch for multiple UI targets
3. insert_data_to_spreadsheet
Type:async (data: List[Dict], startRow?: int, startCol?: int, includeHeaders?: bool) -> dict
Purpose: Insert tabular data directly into spreadsheet cells.
Description:
Inserts an array of row objects into the spreadsheet at the specified position. Each object’s keys become column headers (if includeHeaders=true), and values populate the corresponding cells. Commonly used after fetching data or preparing data arrays.
Parameters:
data(array, required): Array of row objects. Example:[{"id": 1, "name": "John"}, {"id": 2, "name": "Jane"}]startRow(integer, optional): Starting row index (0-based). Default:0startCol(integer, optional): Starting column index (0-based). Default:0includeHeaders(boolean, optional): Add column headers in first row. Default:true
dataarray cannot be empty- All objects should have consistent keys
- Non-empty data is required
4. fetch_and_display
Type:async (query: str, explanation: str, uiTarget?: str, formatting?: dict) -> dict
Purpose: Universal fetch operation routing data to multiple UI component types.
Description:
A versatile tool that executes a SQL query and routes results to the appropriate UI component based on the target. Supports spreadsheets, documents, slides, widgets, dashboards, and formula builders. The uiTarget parameter determines where data is displayed.
Parameters:
query(string, required): SQL query usingschema.tableformatexplanation(string, required): What this query does and whyuiTarget(string, optional): Target UI component:"auto","spreadsheet","document","slide","widget","dashboard","formula". Default:"auto"(routes to spreadsheet)formatting(object, optional): UI-specific formatting options
spreadsheet- Univer Sheets (Excel-like cells/formulas)document- Univer Docs (rich text with tables)slide- Univer Slides (presentation format)widget- Dashboard widget (chart/table)dashboard- Full dashboard layoutformula- Formula builder contextauto- Automatically detect active UI context
Standard Spreadsheet Tools
spreadsheet_set_cell
Type:async (row: int, col: int, value: any, sheetId?: str) -> dict
Purpose: Update a single cell value.
Parameters:
row(integer, required): Row index (0-based)col(integer, required): Column index (0-based)value(any, required): Cell value (string, number, boolean, or null)sheetId(string, optional): Target sheet ID
spreadsheet_get_cell
Type:async (row: int, col: int, sheetId?: str) -> dict
Purpose: Read a cell value from the spreadsheet.
Parameters:
row(integer, required): Row index (0-based)col(integer, required): Column index (0-based)sheetId(string, optional): Target sheet ID
spreadsheet_set_formula
Type:async (row: int, col: int, formula: str, sheetId?: str) -> dict
Purpose: Insert an Excel-style formula into a cell.
Supported Functions:
- Math:
SUM(),AVERAGE(),MIN(),MAX(),ROUND() - Logic:
IF(),AND(),OR(),NOT() - Text:
CONCATENATE(),LEFT(),RIGHT(),MID() - References: Cell references (
A1,B2), Ranges (A1:A10)
spreadsheet_select_range
Type:async (startRow: int, startCol: int, endRow: int, endCol: int, sheetId?: str) -> dict
Purpose: Highlight a range of cells to draw user attention.
Parameters:
startRow(integer, required): Start row (0-based, inclusive)startCol(integer, required): Start column (0-based, inclusive)endRow(integer, required): End row (0-based, inclusive)endCol(integer, required): End column (0-based, inclusive)sheetId(string, optional): Target sheet ID
select_spreadsheet_cell
Type:async (row: int, col: int, sheetId?: str, reason?: str) -> dict
Purpose: Select a single cell with optional guidance message.
Parameters:
row(integer, required): Row index (0-based)col(integer, required): Column index (0-based)sheetId(string, optional): Target sheet IDreason(string, optional): Guidance message for the user
spreadsheet_insert_row
Type:async (rowIndex: int, count?: int, sheetId?: str) -> dict
Purpose: Insert one or more blank rows at a specific position.
Parameters:
rowIndex(integer, required): Row position to insert at (0-based)count(integer, optional): Number of rows to insert (1-100). Default:1sheetId(string, optional): Target sheet ID
Visualization Tools
create_spreadsheet_chart
Type:async (input: CreateSpreadsheetChartInput) -> dict
Purpose: Create visual charts from spreadsheet data.
Description:
Generates charts from data already inserted into the spreadsheet. Charts provide visual representation of trends, comparisons, and distributions. Must be used after data is loaded into cells.
Chart Types:
bar- Horizontal bars, best for category comparisonscolumn- Vertical bars, best for time seriesline- Line graphs, best for trends over timepie- Pie charts, best for proportions/percentagesarea- Area charts, best for cumulative totalsscatter- Scatter plots, best for correlations
title(string, required): Chart titlechartType(string, required): One of the chart types abovedataRange(object, required): Data range specificationstartRow,startCol,endRow,endCol(all integers)
categoryColumn(integer, required): Column index for category labelsseriesColumns(array, required): Column indices for data seriesposition(object, optional): Chart placementstartRow,startCol- Position in spreadsheet
options(object, optional):showLegend(boolean) - Show legend. Default:trueshowDataLabels(boolean) - Show value labels. Default:falsecolors(array) - Custom color array
Analysis Tools
create_pivot_table
Type:async (input: CreatePivotTableInput) -> dict
Purpose: Summarize and aggregate spreadsheet data.
Description:
Creates a pivot table for analyzing data by grouping and calculating aggregations. Essential for cross-tab analysis, totals, and summaries.
Aggregation Functions:
sum- Add valuescount- Count itemsaverage- Calculate meanmax- Find maximummin- Find minimummedian- Find middle value
dataRange(object, required): Source data rangerowFields(array, required): Field names for row groupingcolumnFields(array, optional): Field names for column groupingvalueFields(array, required): Aggregation specificationsfield(string) - Column to aggregateaggregation(string) - Function (sum, count, average, etc.)label(string, optional) - Display label
showSubtotals(boolean, optional): Show subtotal rows. Default:trueshowGrandTotal(boolean, optional): Show grand total. Default:trueposition(object, optional): Output location
spreadsheet_analyze
Type:async (input: SpreadsheetAnalyzeInput) -> dict
Purpose: Generate ASIC RG94-compliant validation rules with AI-powered analysis.
Description:
Uses AI to analyze spreadsheet data and generate regulatory validation rules. Supports NAV reconciliation, cash validation, holdings analysis, fee calculations, and general reconciliation with compliance guidance.
Validation Types:
NAV- Net Asset Value validation (3bp default tolerance)cash- Cash balance reconciliation (zero tolerance)holdings- Position reconciliation (1bp default tolerance)fees- Fee calculation validation (5bp default tolerance)reconciliation- Total assets reconciliation (3bp default tolerance)
range(string, required): Cell range (e.g., “A1:D100”)validationType(string, required): Type of validationcontext(object, optional):fundType(string) - Fund type (e.g., “mutual”, “hedge”, “private equity”)assetClass(string) - Asset class (e.g., “equities”, “fixed income”, “alternatives”)toleranceBps(number) - Custom tolerance in basis points
analysis- AI-generated insights and summarysuggestedRules- Array of ASIC RG94-compliant rulesreferences- Links to regulatory guidance
Use Cases and Workflows
Workflow 1: Import and Visualize Portfolio Data
Workflow 2: NAV Reconciliation
Workflow 3: Holdings Analysis with Pivot Table
Best Practices
- Always Prepare Workspace First: Call
prepare_spreadsheet_workspacebefore other operations - Use Fetch-and-Insert: Prefer
fetch_and_insert_to_spreadsheetover separate fetch/insert calls - Data Before Visualization: Insert data before creating charts or pivot tables
- A1 Notation: Tools use 0-based indexing internally but display A1 notation to users
- Include Headers: Set
includeHeaders=truefor proper column identification - Validate Ranges: Ensure chart/pivot table ranges match actual data
- Compliance-First: Use
spreadsheet_analyzefor regulatory validation scenarios
Related Documentation
- UniverJS Integration - Technical architecture details