Skip to content

#2455 - Added hook for naming copied pivot tables during worksheet copy - #2457

Open
swmal wants to merge 1 commit into
develop8from
feature/i2455
Open

#2455 - Added hook for naming copied pivot tables during worksheet copy#2457
swmal wants to merge 1 commit into
develop8from
feature/i2455

Conversation

@swmal

@swmal swmal commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a naming hook for pivot tables copied during a worksheet copy, mirroring the existing table copy hook. Also fixes a pre-existing bug in ExcelPivotTable.Name that this work surfaced.

See #2455

Changes

Feature

  • New ExcelPivotTableCopyEventArgs (SourceTableName, DefaultName, NewName).
  • New PivotTableCopyHandler on ExcelWorksheetCopyOptions, invoked for each copied pivot table. The caller can set NewName to rename the copy.
  • CopyPivotTable now returns its source→copy name map; an ApplyPivotTableCopyOptions pass runs last in Copy, routing the rename through the ExcelPivotTable.Name setter so name uniqueness is validated. GETPIVOTDATA is address based, so no formula adjustment is needed.

Bug fix

  • ExcelPivotTable.Name validated and bookkept against the table collection (_tableNames / ExistsTableName) — a copy-paste from ExcelTable. Corrected to the pivot collection (_pivotTableNames / ExistsPivotTableName). The copy constructor no longer sets the name via the setter, avoiding a double registration in _pivotTableNames.

Tests

Added coverage in CopyWorksheetTests for default generated naming, the rename hook, source/default name context, null NewName, name-collision rejection, and GETPIVOTDATA resolution after rename. Existing PivotTableTests (range-copy path) remain green.

@swmal swmal self-assigned this Aug 6, 2026
@swmal swmal added the enhancement New feature or request label Aug 6, 2026
@swmal swmal changed the title #2455 - Addedgit status hook for naming copied pivot tables during worksheet copy #2455 - Added hook for naming copied pivot tables during worksheet copy Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant