read_sheet
Extract spreadsheet data as structured rows, with optional bounds to limit output for large sheets. Returns cell values with empty cells as null.
Instructions
Read an entire sheet (or a bounded sub-region) as a list of rows.
Each row is a list of cell values. Empty cells appear as null. Use the optional row/column bounds to limit output for large sheets.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | Path to the spreadsheet file | |
| sheet | No | Sheet name. Defaults to the first sheet if omitted. | |
| start_row | No | First row to include (1-based). Defaults to the first used row. | |
| end_row | No | Last row to include (1-based). Defaults to the last used row. | |
| start_column | No | First column to include (1-based, e.g. 1 = A). Defaults to the first used column. | |
| end_column | No | Last column to include (1-based). Defaults to the last used column. |
Implementation Reference
- The implementation of the `read_sheet` MCP tool, which reads an entire sheet or a sub-region into a 2D list.
def read_sheet( file: Annotated[str, Field(description="Path to the spreadsheet file")], sheet: Annotated[str | None, Field(description="Sheet name. Defaults to the first sheet if omitted.")] = None, start_row: Annotated[int | None, Field(description="First row to include (1-based). Defaults to the first used row.")] = None, end_row: Annotated[int | None, Field(description="Last row to include (1-based). Defaults to the last used row.")] = None, start_column: Annotated[int | None, Field(description="First column to include (1-based, e.g. 1 = A). Defaults to the first used column.")] = None, end_column: Annotated[int | None, Field(description="Last column to include (1-based). Defaults to the last used column.")] = None, ) -> list[list]: """Read an entire sheet (or a bounded sub-region) as a list of rows. Each row is a list of cell values. Empty cells appear as null. Use the optional row/column bounds to limit output for large sheets. """ wb = load_workbook(file) ws = _resolve_sheet(wb, sheet) rows = ws.iter_rows( min_row=start_row, max_row=end_row, min_col=start_column, max_col=end_column, ) return [list(r) for r in rows]