-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Issue Description
When using LoadTo to load a Power Query to a worksheet, if a sheet with that name already exists, the operation appears to succeed but the query remains in "Connection Only" mode. This results in silent failure where the user believes data was loaded but it's actually not visible anywhere.
Steps to Reproduce
- Create a worksheet named "Milestone Export" in Excel
- Create a Power Query named "Milestone Export" (connection-only initially)
- Use ExcelMcp to load the query to a worksheet:
excel_powerquery(action: 'LoadTo', queryName: 'Milestone Export', targetSheet: 'Milestone Export') - Expected: Query loads data to the existing "Milestone Export" sheet, or fails with a clear error
- Actual: Operation reports success but query remains in "Connection Only" mode with no data loaded
Root Cause
When a sheet with the target name already exists, Excel silently fails to change the query's load configuration. The ExcelMcp tool reports success (based on the COM call succeeding), but the actual load destination isn't changed.
Observed Behavior
LoadTo returns:
"success": true,
"queryName": "Milestone Export",
"loadDestination": "LoadToTable",
"worksheetName": "Milestone Export",
"configurationApplied": true,
"dataRefreshed": true,
"rowsLoaded": 60
However, checking the load configuration shows:
"loadMode": "ConnectionOnly",
"targetSheet": null
The query never actually loaded to the sheet.
Workaround
Delete the target worksheet first, then use LoadTo:
# Delete existing sheet with same name
excel_worksheet(action: 'Delete', sheetName: 'Milestone Export')
# Now LoadTo will work correctly
excel_powerquery(action: 'LoadTo', queryName: 'Milestone Export', targetSheet: 'Milestone Export')Impact
- Silent Data Loss: Users believe data is loaded when it isn't
- Misleading Success Response: ExcelMcp reports success, making the issue hard to detect
- Confusing UX: No error or warning that the sheet name conflict prevented loading
Proposed Solutions
- Auto-delete conflicting sheet: When
LoadTodetects a sheet with the target name exists, automatically delete it before loading - Return accurate status: Verify the load configuration was actually changed and return failure if it wasn't
- Add
overwriteparameter: Let users explicitly control whether to overwrite existing sheets - Better error detection: Check for sheet name conflicts and return a clear error message
Environment
- ExcelMcp Server: Latest version
- Excel: Excel 365
- Scenario: Power Query using
LoadTowhen target sheet name already exists
Related
This issue was discovered while debugging consumption milestone generation. The query appeared to refresh successfully, but no data was visible because the query remained connection-only due to a pre-existing sheet with the same name.