autofit_sheet_columns

Auto-resize columns to fit their content — wraps Sheets `autoResizeDimensions`.

writeGoogle Sheets, Docs & Drive

No more guessing pixel widths.

Call it

In an AI client (MCP)

tools/call
{
  "name": "autofit_sheet_columns",
  "arguments": {
    "spreadsheet_id": "<spreadsheet_id>",
    "sheet_name": "<sheet_name>"
  }
}

From code (Tool API)

curl -X POST https://api.sellersheetai.com/api/v1/tools/autofit_sheet_columns \
  -H "Authorization: Bearer $SELLERSHEET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"spreadsheet_id":"<spreadsheet_id>","sheet_name":"<sheet_name>"}'
Early access — the Tool API is open on request, contact us.

Arguments

NameTypeDescription
spreadsheet_idrequiredstringthe spreadsheet ID (from its URL or get_sheet_metadata).
sheet_namerequiredstringthe tab name.
start_colinteger0-based start column index. Default 0 (column A).Default: 0
end_colinteger0-based exclusive end. None = autofit every column the tab has (uses gridProperties.columnCount).

Result

Every tool answers {notification, data, human_action}; data carries:

  • data.startCol / data.endCol — the column span fitted (0-based, end exclusive).
  • data.sheetId — the tab's id.

Example

# autofit columns A–F
autofit_sheet_columns("1ABC...", "Summary", start_col=0, end_col=6)
# autofit the whole tab
autofit_sheet_columns("1ABC...", "Summary")

On this page

Actions

View as Markdown

Ask an assistant

Ask ChatGPTAsk Claude