Sheets API
This guide shows how to work with Athena Sheets programmatically using the TypeScript SDK. The Sheets API provides comprehensive functionality for reading data, updating cells, managing tables, formatting, and more.
Key features:
- Cell Operations - Update individual cells or ranges of cells
- Table Management - Create, read, and modify structured tables
- Formatting - Apply formatting to cells and ranges
- Row & Column Operations - Insert, delete, and manage rows and columns
- Sheet Management - Create, duplicate, and manage sheet tabs
- Full TypeScript support - Complete type safety with proper interfaces
Cell Operations
Update a Single Cell
Update the value of a specific cell in a spreadsheet.
Update a Range of Cells
Update multiple cells at once with a 2D array of values.
Update Range with Formatting
Apply formatting while updating cell values.
Delete Cells
Delete cells in a specified range (shifts cells up or left).
Range Operations
Clear a Range
Clear the contents of cells in a range without deleting them.
Format a Range
Apply formatting to a range of cells.
Clear Formatting
Remove all formatting from a range of cells.
Row and Column Operations
Insert a Row
Insert one or more new rows at a specific position.
Insert a Column
Insert a new column at a specific position.
Delete Columns
Delete one or more columns.
Sheet Management
Create a New Sheet Tab
Add a new sheet tab to the spreadsheet.
Duplicate a Sheet
Create a copy of an existing sheet.
Table Operations
Tables in Athena Sheets provide structured data with named columns, making it easier to work with data programmatically.
Create a Table
Create a new table from a range of cells.
Get Table Data
Retrieve all data from a table including column names and rows.
Insert Table Row
Add new rows to a table with structured data.
Update Table
Modify the range of an existing table.
Insert Table Column
Add a new column to an existing table.
Delete Table Column
Remove a column from a table.
Complete Example: Managing Employee Data
Here’s a complete example that demonstrates multiple operations:
Type Definitions
Cell Format Options
The CellFormat
interface provides extensive formatting options:
Response Types
All sheet operations return a SheetOperationResponse
:
The getTable
operation returns a GetTableResponse
:
The createTab
operation returns a CreateNewSheetTabResponse
:
Best Practices
- Use Tables for Structured Data: Tables provide better data management with named columns
- Batch Operations: Use
updateRange
instead of multipleupdateCell
calls for better performance - Format Headers: Apply consistent formatting to header rows for better readability
- Error Handling: Always check the
success
field in responses - Asset IDs: Store spreadsheet asset IDs securely and reuse them
- Sheet IDs: Keep track of sheet IDs when working with multi-sheet spreadsheets
- 1-Based Indexing: Remember that rows and columns use 1-based indexing (row 1, column 1 = A1)
- Table Operations: Use 0-based
dimension_index
for table column operations
Next Steps
- Explore the full API reference for detailed information
- Learn about Agents for AI-powered automation
- Check out file upload to work with local spreadsheets