insert_columns
Add blank columns to spreadsheets by specifying position and quantity, shifting existing columns right to organize data.
Instructions
Insert one or more blank columns, shifting existing columns right.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | Path to the spreadsheet file | |
| column | Yes | 1-based column index where new columns will be inserted (e.g. 1 = A, 2 = B). Existing columns at and to the right shift right. | |
| count | No | Number of blank columns to insert | |
| sheet | No | Sheet name. Defaults to the first sheet if omitted. |
Implementation Reference
- The 'insert_columns' tool handler implemented in src/mcp_server_spreadsheet/server.py.
def insert_columns( file: Annotated[str, Field(description="Path to the spreadsheet file")], column: Annotated[int, Field(description="1-based column index where new columns will be inserted (e.g. 1 = A, 2 = B). Existing columns at and to the right shift right.")], count: Annotated[int, Field(description="Number of blank columns to insert")] = 1, sheet: Annotated[str | None, Field(description="Sheet name. Defaults to the first sheet if omitted.")] = None, ) -> str: """Insert one or more blank columns, shifting existing columns right.""" wb = load_workbook(file) ws = _resolve_sheet(wb, sheet) ws.insert_cols(column, count) wb.save(file) return f"Inserted {count} columns at column {column}"