excel-mcp by sbroenne/mcp-server-excel
npx skills add https://github.com/sbroenne/mcp-server-excel --skill excel-mcp通过 Model Context Protocol 提供 227 项 Excel 操作。该 MCP Server 将所有请求转发至共享的 ExcelMCP Service,实现与 CLI 的会话共享。工具可自动发现——本文档记录了其特性、工作流程和注意事项。
| 步骤 | 工具 | 操作 | 时机 |
|---|---|---|---|
| 1. 打开文件 | file | open 或 create | 始终第一步 |
| 2. 创建工作表 | worksheet | create, rename |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 如果需要 |
| 3. 写入数据 | range | set-values | 始终(二维数组) |
| 4. 格式设置 | range | set-number-format | 写入数据后 |
| 5. 结构化 | table | create | 将数据转换为表格 |
| 6. 保存并关闭 | file | close 并设置 save: true | 始终最后一步 |
C:\Users\Name\Documents\Report.xlsx使用 calculation_mode 进行批量写入性能优化。当写入大量值或公式时,禁用自动重新计算以避免在每个单元格后都重新计算:
1. calculation_mode(action: 'set-mode', mode: 'manual') → 禁用自动重新计算
2. 执行所有写入操作(range set-values, set-formulas)
3. calculation_mode(action: 'calculate', scope: 'workbook') → 一次性重新计算
4. calculation_mode(action: 'set-mode', mode: 'automatic') → 恢复默认设置
注意: 读取公式时不需要手动模式——无论计算模式如何,range get-formulas 都会返回公式文本。
停。 如果你正要问“哪个文件?”、“什么表?”、“我应该把这个放在哪里?”——不要问。
| 错误(询问) | 正确(发现) |
|---|---|
| "我应该使用哪个 Excel 文件?" | file(list) → 使用已打开的会话 |
| "表名是什么?" | table(list) → 发现表格 |
| "哪个工作表有数据?" | worksheet(list) → 检查所有工作表 |
| "我应该创建数据透视表吗?" | 是的——在新工作表上创建 |
你有工具可以自己找到答案。使用它们。
绝不要仅以一个工具调用结束你的回合。 完成所有操作后,始终提供一个简短的文本消息来确认已完成的操作。仅包含工具调用的静默响应是不完整的。
在设置值之后始终应用数字格式:
| 数据类型 | 格式代码 | 结果 |
|---|---|---|
| 美元 | $#,##0.00 | $1,234.56 |
| 欧元 | €#,##0.00 | €1,234.56 |
| 百分比 | 0.00% | 15.00% |
| 日期(ISO) | yyyy-mm-dd | 2025-01-22 |
工作流程:
1. range set-values (数据现在在单元格中)
2. range set-number-format (应用格式)
始终将表格数据转换为 Excel 表格:
1. range set-values (写入数据,包括表头)
2. table create tableName="SalesData" rangeAddress="A1:D100"
原因: 结构化引用、自动扩展,是数据模型/DAX 所必需的。
1. file(action: 'open', path: '...') → sessionId
2. 所有操作都使用 sessionId
3. file(action: 'close', save: true) → 保存并关闭
未关闭的会话会使 Excel 进程持续运行,锁定文件。
DAX 操作要求表格存在于数据模型中:
步骤 1: 创建表格 → 表格存在
步骤 2: table(action: 'add-to-datamodel') → 表格加入数据模型
步骤 3: datamodel(action: 'create-measure') → 现在可以工作
最佳实践:测试优先工作流程
1. powerquery(action: 'evaluate', mCode: '...') → 测试,但不持久化
2. powerquery(action: 'create', ...) → 存储已验证的查询
3. powerquery(action: 'refresh', ...) → 加载数据
为什么先进行评估:
常见错误: 未经评估就创建/更新 → 用损坏的查询污染工作簿
set-values(例如,第 5 行的 A5:C5)原因: 保留格式、公式和引用。
错误响应包含可操作的提示:
{
"success": false,
"errorMessage": "在数据模型中未找到表 'Sales'",
"suggestedNextActions": ["table(action: 'add-to-data-model', tableName: 'Sales')"]
}
当写入大量值/公式(10 个以上单元格)时,使用 calculation_mode 以避免每次写入后都重新计算:
1. calculation_mode(action: 'set-mode', mode: 'manual') → 禁用自动重新计算
2. 执行数据写入操作(range set-values, set-formulas)
3. calculation_mode(action: 'calculate', scope: 'workbook') → 最后一次性重新计算
4. calculation_mode(action: 'set-mode', mode: 'automatic') → 恢复默认设置
不需要的情况: 读取公式、少量编辑(1-10 个单元格),或需要立即获取计算结果时。
| 任务 | 工具 | 关键操作 |
|---|---|---|
| 创建/打开/保存工作簿 | file | open, create, close |
| 写入/读取单元格数据 | range | set-values, get-values |
| 格式化单元格 | range | set-number-format |
| 从数据创建表格 | table | create |
| 将表格添加到 Power Pivot | table | add-to-data-model |
| 创建 DAX 公式 | datamodel | create-measure |
| 创建数据透视表 | pivottable | create, create-from-datamodel |
| 使用切片器筛选 | slicer | set-slicer-selection |
| 创建图表 | chart | create-from-range |
| 控制计算模式 | calculation_mode | get-mode, set-mode, calculate |
| 视觉验证 | screenshot | capture, capture-sheet |
详细指南请参阅 references/:
每周安装量
657
代码仓库
GitHub 星标数
94
首次出现
2026年1月22日
安全审计
安装于
opencode592
gemini-cli577
codex574
github-copilot567
cursor543
kimi-cli534
Provides 227 Excel operations via Model Context Protocol. The MCP Server forwards all requests to the shared ExcelMCP Service, enabling session sharing with CLI. Tools are auto-discovered - this documents quirks, workflows, and gotchas.
| Step | Tool | Action | When |
|---|---|---|---|
| 1. Open file | file | open or create | Always first |
| 2. Create sheets | worksheet | create, rename | If needed |
| 3. Write data | range | set-values | Always (2D arrays) |
| 4. Format | range | set-number-format | After writing |
| 5. Structure | table | create | Convert data to tables |
| 6. Save & close | file | close with save: true | Always last |
C:\Users\Name\Documents\Report.xlsxUse calculation_mode for bulk write performance optimization. When writing many values or formulas, disable auto-recalc to avoid recalculating after every cell:
1. calculation_mode(action: 'set-mode', mode: 'manual') → Disable auto-recalc
2. Perform all writes (range set-values, set-formulas)
3. calculation_mode(action: 'calculate', scope: 'workbook') → Recalculate once
4. calculation_mode(action: 'set-mode', mode: 'automatic') → Restore default
Note: You do NOT need manual mode to read formulas - range get-formulas returns formula text regardless of calculation mode.
STOP. If you're about to ask "Which file?", "What table?", "Where should I put this?" - DON'T.
| Bad (Asking) | Good (Discovering) |
|---|---|
| "Which Excel file should I use?" | file(list) → use the open session |
| "What's the table name?" | table(list) → discover tables |
| "Which sheet has the data?" | worksheet(list) → check all sheets |
| "Should I create a PivotTable?" | YES - create it on a new sheet |
You have tools to answer your own questions. USE THEM.
NEVER end your turn with only a tool call. After completing all operations, always provide a brief text message confirming what was done. Silent tool-call-only responses are incomplete.
Always apply number formats after setting values:
| Data Type | Format Code | Result |
|---|---|---|
| USD | $#,##0.00 | $1,234.56 |
| EUR | €#,##0.00 | €1,234.56 |
| Percent | 0.00% | 15.00% |
| Date (ISO) | yyyy-mm-dd | 2025-01-22 |
Workflow:
1. range set-values (data is now in cells)
2. range set-number-format (apply format)
Always convert tabular data to Excel Tables:
1. range set-values (write data including headers)
2. table create tableName="SalesData" rangeAddress="A1:D100"
Why: Structured references, auto-expand, required for Data Model/DAX.
1. file(action: 'open', path: '...') → sessionId
2. All operations use sessionId
3. file(action: 'close', save: true) → saves and closes
Unclosed sessions leave Excel processes running, locking files.
DAX operations require tables in the Data Model:
Step 1: Create table → Table exists
Step 2: table(action: 'add-to-datamodel') → Table in Data Model
Step 3: datamodel(action: 'create-measure') → NOW this works
BEST PRACTICE: Test-First Workflow
1. powerquery(action: 'evaluate', mCode: '...') → Test WITHOUT persisting
2. powerquery(action: 'create', ...) → Store validated query
3. powerquery(action: 'refresh', ...) → Load data
Why evaluate first:
Common mistake: Creating/updating without evaluate → pollutes workbook with broken queries
set-values on specific range (e.g., A5:C5 for row 5)Why: Preserves formatting, formulas, and references.
Error responses include actionable hints:
{
"success": false,
"errorMessage": "Table 'Sales' not found in Data Model",
"suggestedNextActions": ["table(action: 'add-to-data-model', tableName: 'Sales')"]
}
When writing many values/formulas (10+ cells), use calculation_mode to avoid recalculating after every write:
1. calculation_mode(action: 'set-mode', mode: 'manual') → Disable auto-recalc
2. Perform data writes (range set-values, set-formulas)
3. calculation_mode(action: 'calculate', scope: 'workbook') → Recalculate once at end
4. calculation_mode(action: 'set-mode', mode: 'automatic') → Restore default
When NOT needed: Reading formulas, small edits (1-10 cells), or when you need immediate calculation results.
| Task | Tool | Key Action |
|---|---|---|
| Create/open/save workbooks | file | open, create, close |
| Write/read cell data | range | set-values, get-values |
| Format cells | range | set-number-format |
| Create tables from data | table | create |
| Add table to Power Pivot | table | add-to-data-model |
See references/ for detailed guidance:
Weekly Installs
657
Repository
GitHub Stars
94
First Seen
Jan 22, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
opencode592
gemini-cli577
codex574
github-copilot567
cursor543
kimi-cli534
Azure Data Explorer (Kusto) 查询技能:KQL数据分析、日志遥测与时间序列处理
98,500 周安装
多语言测试生成技能 - AI驱动单元测试生成工具,支持多种编程语言
7,500 周安装
对话音频生成工具:使用Dia TTS创建逼真多说话人对话,支持情感控制和节奏调整
7,400 周安装
Transloadit 云端媒体处理 | 视频编码、图像优化、音频转码、OCR 文档
7,400 周安装
Power BI 数据模型设计审查指南 - 架构、性能与可维护性全面评估
7,400 周安装
PHP MCP服务器生成器 - 快速创建生产级MCP服务器项目 | PHP 8.2+
7,400 周安装
GitHub Copilot AI模型推荐工具:根据任务复杂度自动选择最佳AI模型
7,400 周安装
| Create DAX formulas | datamodel | create-measure |
| Create PivotTables | pivottable | create, create-from-datamodel |
| Filter with slicers | slicer | set-slicer-selection |
| Create charts | chart | create-from-range |
| Control calculation mode | calculation_mode | get-mode, set-mode, calculate |
| Visual verification | screenshot | capture, capture-sheet |