Files
sbroenne__mcp-server-excel/tests/ExcelMcp.ComInterop.Tests
Stefan Broenner 72c968c0ba feat: Add cross-workbook worksheet operations (copy-to-workbook, move-to-workbook) (#231)
Implements GitHub issue #187 - Enable copying and moving worksheets between different Excel workbooks.

**Architecture Changes:**
- Extended IExcelBatch to support multiple workbooks in single Excel.Application instance
- Added Workbooks property (IReadOnlyDictionary<string, dynamic>) and GetWorkbook(string) method
- Modified ExcelBatch constructor to accept string[] workbookPaths and open all in shared COM context
- Updated ExcelSession.BeginBatch to accept params string[] filePaths

**Core Implementation:**
- Added CopyToWorkbook and MoveToWorkbook methods to ISheetCommands
- Implemented using Excel COM Worksheet.Copy and Worksheet.Move APIs
- Extended List() and Create() with optional filePath parameter for multi-workbook scenarios
- Uses batch.GetWorkbook(filePath) to target specific workbook in multi-file batches

**MCP Server:**
- Updated ExcelWorksheetTool to create temporary multi-file batches for cross-workbook operations
- Added comprehensive cross-workbook documentation to tool description
- Updated excel_worksheet.md prompt with workflow examples and guidance

**Tests:**
- Converted 10 cross-workbook tests from error-handling to positive validation
- Updated 18 test files for new ExcelBatch constructor signature (array parameter)
- All 9 cross-workbook integration tests passing

**Documentation:**
- Updated README.md: 13→16 worksheet actions, added cross-workbook capability
- Updated CLI README: Added copy-to-workbook/move-to-workbook examples
- Updated GitHub Pages: 158 operations (fixed inconsistencies), comprehensive action tables
- Updated vscode-extension README: Already correct (16 actions)

**Key Benefits:**
- Single Excel.Application for multiple workbooks = proper COM object sharing
- No RCW isolation issues between batches
- Clean multi-workbook API: ExcelSession.BeginBatch(file1, file2, file3)
- LLMs now have clear guidance on when/how to use cross-workbook operations
2025-11-22 12:45:23 +00:00
..
2025-11-17 09:27:59 +00:00
2025-11-17 09:27:59 +00:00