Skip to content

feat(googleSheets): auto-collapse pivot table outer row groups on export - #3

Open
andrewleverette wants to merge 1 commit into
masterfrom
feat/google-sheets-auto-collapse-pivot-table
Open

feat(googleSheets): auto-collapse pivot table outer row groups on export#3
andrewleverette wants to merge 1 commit into
masterfrom
feat/google-sheets-auto-collapse-pivot-table

Conversation

@andrewleverette

Copy link
Copy Markdown
Collaborator

Summary

Collapses every pivot table's outer-most row-field group before exporting a Google Sheets template report as xlsx, so the rendered file shows only header/Total rows instead of every expanded detail row.

Changes

  • GoogleSheetsClient.CollapsePivotTables(spreadsheetId): reads each pivot table's rendered cell text to discover current group values (freshly written pivots have no pre-existing ValueMetadata), merges Collapsed = true into the outer-most PivotGroup's ValueMetadata per discovered value (preserving entries for values not currently rendered), and writes the whole PivotTable back via UpdateCells. Requests are batched in chunks of 100 via batchUpdate.
  • GoogleSheetsTemplateReportControl: calls CollapsePivotTables as a best-effort step before export — a failure is logged but doesn't block the report from being generated.
  • GoogleSheetsClientException: adds the Collapse error type.

Notes

This mirrors the pivot-collapsing algorithm and Google Sheets API call shapes used in the node-utility project's googleSheetsClient (same constants, same detection/merge logic, same updateCells/batchUpdate request shapes), verified by direct comparison.

Collapse every pivot table's outer-most row-field group before exporting a Google Sheets template report as xlsx, so the rendered file shows only header/Total rows instead of every expanded detail row.

- Read each pivot table's rendered cell text to discover current group values (freshly written pivots have no pre-existing ValueMetadata).
- Merge Collapsed = true into the outer-most PivotGroup's ValueMetadata per discovered value, preserving entries for values not currently rendered, and write the whole PivotTable back via UpdateCells.
- Batch collapse requests (chunks of 100) via batchUpdate.
- Wire into GoogleSheetsTemplateReportControl as a best-effort step: a collapse failure is logged but doesn't block export.

Mirrors the pivot-collapsing algorithm and Sheets API call shapes used in the node-utility project's googleSheetsClient.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

1 participant