delete_columns
Remove specified columns from spreadsheet files to clean data or restructure layouts, shifting remaining columns left automatically.
Instructions
Delete one or more columns, shifting remaining columns left.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | Path to the spreadsheet file | |
| column | Yes | 1-based index of the first column to delete (e.g. 1 = A, 2 = B) | |
| count | No | Number of consecutive columns to delete starting from column | |
| sheet | No | Sheet name. Defaults to the first sheet if omitted. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- The delete_columns tool implementation, which loads the spreadsheet, resolves the sheet, deletes the specified range of columns, saves the file, and returns a confirmation message.
@mcp.tool() def delete_columns( file: Annotated[str, Field(description="Path to the spreadsheet file")], column: Annotated[int, Field(description="1-based index of the first column to delete (e.g. 1 = A, 2 = B)")], count: Annotated[int, Field(description="Number of consecutive columns to delete starting from column")] = 1, sheet: Annotated[str | None, Field(description="Sheet name. Defaults to the first sheet if omitted.")] = None, ) -> str: """Delete one or more columns, shifting remaining columns left.""" wb = load_workbook(file) ws = _resolve_sheet(wb, sheet) ws.delete_cols(column, count) wb.save(file) return f"Deleted {count} columns at column {column}"