delete_sheet
Remove a specific sheet from a spreadsheet file to delete its data permanently. Works with .xlsx and .ods formats.
Instructions
Delete a sheet by name from the workbook.
All data in the sheet is permanently removed. Not supported for CSV files.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | Path to the spreadsheet file | |
| name | Yes | Name of the sheet to delete |
Implementation Reference
- The MCP tool handler for 'delete_sheet', which loads the workbook, deletes the sheet using the backend's delete_sheet method, saves the changes, and returns a confirmation string.
def delete_sheet( file: Annotated[str, Field(description="Path to the spreadsheet file")], name: Annotated[str, Field(description="Name of the sheet to delete")], ) -> str: """Delete a sheet by name from the workbook. All data in the sheet is permanently removed. Not supported for CSV files. """ wb = load_workbook(file) wb.delete_sheet(name) wb.save(file) return f"Deleted sheet {name!r}"