feat(sheets): add table manipulation commands with smart sheet resolution#470
Open
Pedrohgv wants to merge 6 commits intosteipete:mainfrom
Open
feat(sheets): add table manipulation commands with smart sheet resolution#470Pedrohgv wants to merge 6 commits intosteipete:mainfrom
Pedrohgv wants to merge 6 commits intosteipete:mainfrom
Conversation
…ate, append, clear, delete) Adds comprehensive support for Google Sheets Tables API: - list: List all tables in a spreadsheet - get: Get table details with columns and types - create: Create new tables with column definitions - update: Modify table properties (name, range, footer) - append: Add rows to tables (respects footer) - clear: Clear table contents - delete: Delete tables (or unformat to keep data) Table IDs are handled as strings per API spec. Column types supported: TEXT, NUMBER, DATE, DROPDOWN, CHECKBOX, PERCENT, RATING, CURRENCY, DATE_TIME, TIME, SMART_CHIP
Fixes bug where all rows were flattened into a single row. Now creates separate RowData entries for each input row.
Fixes table clear and other commands that were generating invalid ranges like 'Sheet0!A1:D10' instead of proper A1 notation 'Sheet1!A1:D10'. Changes: - formatGridRange() now accepts sheetName parameter - All callers updated to pass actual sheet name from properties - Added nil checks for safety - Fixed Fields() calls to include sheets.properties.title
TableId is an identifier, not an updatable field. Including it in the fields list caused API errors. Now footer toggle works correctly.
Improvements: 1. Smart Range Parsing: parseA1ToGridRangeWithLookup() resolves sheet names to IDs using spreadsheet metadata. Tables now created on correct sheets. 2. Footer Formula Preservation: Before append, captures footer formulas. After append, checks if table expanded. If expanded, re-applies formulas to new footer row. - Tables can now be created on any sheet (not just Sheet1) - Footer formulas automatically preserved when table expands - Added sheet name resolution helper function
Fixes critical bug where appended data went to Sheet1 instead of the table's actual sheet (e.g., TestSheet, SalesData). Changed from AppendCellsRequest (TableId only) to Values.Append with explicit sheet name in range (SheetName!Col:Col). This ensures data is appended to the correct sheet location. Also updates JSON output to use AppendValuesResponse fields.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(sheets): add table manipulation commands with smart sheet resolution
What is this feature?
Adds comprehensive Google Sheets Tables API support to gogcli. Tables are structured Excel-like data containers with typed columns (dropdowns, dates, percentages), headers, footers, and named references. This feature enables programmatic table creation, data manipulation, and aggregation via the CLI.
Key Features
=SUM(TableName[Column])syntax for formulasUsage Examples
Implementation Details
Smart Range Parsing:
parseA1ToGridRangeWithLookup()resolves sheet names (e.g., "SalesData") to actual sheet IDs using spreadsheet metadata. This ensures tables are created on the correct sheet, not just Sheet1.Footer Formula Preservation: Before append, captures footer cell formulas. After append, detects table expansion by comparing ranges. If expanded, re-applies formulas to the new footer row location using
Values.Update.Sheet Location Fix: Changed from
AppendCellsRequest(which ignored table sheet location) toValues.Appendwith explicit sheet name in range (SheetName!Col:Col), ensuring data appends to the correct sheet.Commits
feat(sheets): add table manipulation commands— initial implementation (7 commands, 871 lines)fix(sheets): correct table append for multiple rows— fixed row flattening bugfix(sheets): correct table range formatting— use sheet names in A1 notationfix(sheets): footer update field mask— removed tableId from fields listfeat(sheets): smart range parsing + footer preservation— sheet ID lookup and formula preservationfix(sheets): make append respect sheet location— fixed critical sheet routing bugFiles Changed
internal/cmd/sheets_table.go— new file with all table commands (992 lines)internal/cmd/sheets.go— addedTable SheetsTableCmdfieldTesting
Comprehensive manual testing performed:
Checklist
make build)