Skip to content

Add autoResizeColumns and setColumnWidths tools#80

Merged
a-bonus merged 1 commit intoa-bonus:mainfrom
heyrocker:feat/column-width-tools
Mar 14, 2026
Merged

Add autoResizeColumns and setColumnWidths tools#80
a-bonus merged 1 commit intoa-bonus:mainfrom
heyrocker:feat/column-width-tools

Conversation

@heyrocker
Copy link
Copy Markdown
Contributor

Summary

  • autoResizeColumns — auto-fits columns to their content using the Sheets API autoResizeDimensions batchUpdate. Accepts an optional column range in A1 notation (e.g. "A:S") to limit which columns are resized; defaults to all columns.
  • setColumnWidths — sets explicit pixel widths for one or more columns in a single call. Accepts an array of { column, width } specs; each column can be a single letter ("A") or a contiguous range ("B:D").

Helper logic for setColumnWidths lives in googleSheetsApiHelpers.ts alongside the existing sheet helpers.

Both tools follow existing conventions: camelCase verb-first names, Zod parameters with .describe() on every field, UserError for user-facing errors, plain string return values consistent with other write-operation tools (e.g. formatCells, freezeRowsAndColumns).

Test plan

  • autoResizeColumns with no columns arg resizes all columns
  • autoResizeColumns with columns: "A:C" resizes only columns A through C
  • setColumnWidths with a single column spec sets the correct pixel width
  • setColumnWidths with multiple specs applies all widths in one batchUpdate
  • Both tools return a descriptive success string on success
  • Both tools throw UserError on invalid spreadsheet ID or missing permissions
  • npm run format:check passes
  • npm run build passes with no TypeScript errors

🤖 Generated with Claude Code

Adds two new Google Sheets tools:

- autoResizeColumns: auto-fits columns to their content using the
  Sheets API autoResizeDimensions batchUpdate. Accepts an optional
  column range (e.g. "A:S") to limit which columns are resized.

- setColumnWidths: sets explicit pixel widths for one or more columns.
  Accepts an array of { column, width } specs; each column can be a
  single letter ("A") or range ("B:D").

The setColumnWidths helper logic lives in googleSheetsApiHelpers.ts
and is shared with the tool implementation.
@a-bonus a-bonus merged commit 3dd36a9 into a-bonus:main Mar 14, 2026
@a-bonus
Copy link
Copy Markdown
Owner

a-bonus commented Mar 14, 2026

Thanks for your contribution 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants