Skip to content

Comments

fix: quote sheet names in chart/pivot source refs, improve rename param docs#514

Merged
sbroenne merged 1 commit intomainfrom
fix/512-513-sheet-name-quoting-and-rename-params
Feb 23, 2026
Merged

fix: quote sheet names in chart/pivot source refs, improve rename param docs#514
sbroenne merged 1 commit intomainfrom
fix/512-513-sheet-name-quoting-and-rename-params

Conversation

@sbroenne
Copy link
Owner

Summary

Fixes two bugs reported in the Excel MCP bug report (2026-02-23):

Bug 1 & 3: Sheet name quoting in COM source data references (#512)

Root cause: ChartCommands.Lifecycle.cs and PivotTableCommands.Create.cs construct source data references as $"{sourceSheet}!{sourceRange}" without quoting the sheet name. Excel COM requires single quotes for sheet names with spaces or special characters: 'Sheet Name'!A1:D6.

Fix: Wrap sheet names in single quotes (safe for all names, even without spaces).

Files changed:

  • src/ExcelMcp.Core/Commands/Chart/ChartCommands.Lifecycle.cs — quote sheet name in \CreateFromRange\
  • src/ExcelMcp.Core/Commands/PivotTable/PivotTableCommands.Create.cs — same fix for pivot cache source data

Bug 2: Worksheet rename parameter discoverability (#513)

Root cause: \ExcelWorksheetTool.cs\ is manually written (not source-generated) and the \ arget_name\ parameter description only mentioned "copied" worksheet, not "renamed".

Fix: Updated XML doc to: "New name for the worksheet (required for: rename, copy)"

File changed:

  • \src/ExcelMcp.McpServer/Tools/ExcelWorksheetTool.cs\

Regression Tests (12 new)

Test File Tests Coverage
\ChartCommandsTests.BugRegression.cs\ 4 Sheet names with spaces, data at non-first row
\PivotTableCommandsTests.BugRegression.cs\ 3 Source/dest with spaces, hyphen in name
\WorksheetRenameParameterTests.cs\ 5 MCP parameter contract tests

All 12 tests pass. Pre-commit hooks pass (COM leak check, coverage audit, CLI workflow, MCP smoke test).

Closes #512, closes #513

…am docs (#512, #513)

Bug fixes:
- Chart create-from-range: wrap sheet name in single quotes for COM source data reference
- PivotTable create-from-range: same quoting fix for pivot cache source data
- Worksheet rename: update target_name XML doc to mention rename action

Regression tests (12 new):
- 4 chart tests (sheet names with spaces, data at non-first row)
- 3 pivot table tests (source/dest sheet with spaces, hyphen in name)
- 5 MCP server worksheet rename parameter contract tests

Closes #512, closes #513
@github-actions
Copy link

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@sbroenne sbroenne merged commit 3999024 into main Feb 23, 2026
4 checks passed
@sbroenne sbroenne deleted the fix/512-513-sheet-name-quoting-and-rename-params branch February 23, 2026 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant