一键导入
excel-mcp-automation
AI-powered Excel automation via COM API - 25 tools, 230 operations for Power Query, DAX, VBA, PivotTables, Charts, and more (Windows only)
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
AI-powered Excel automation via COM API - 25 tools, 230 operations for Power Query, DAX, VBA, PivotTables, Charts, and more (Windows only)
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | excel-mcp-automation |
| description | AI-powered Excel automation via COM API - 25 tools, 230 operations for Power Query, DAX, VBA, PivotTables, Charts, and more (Windows only) |
| triggers | ["automate excel with AI","create excel pivottable","generate power query script","format excel ranges","work with excel vba","build excel charts","manage excel data model","create excel tables"] |
Skill by ara.so — MCP Skills collection.
ExcelMcp is a Model Context Protocol (MCP) server and CLI that enables AI assistants to automate Microsoft Excel through natural language. It uses Excel's native COM API (100% safe, zero file corruption risk) to control the actual Excel application on Windows.
Key Capabilities:
Requirements:
Install from VS Code Marketplace:
code --install-extension sbroenne.excel-mcp
Download .mcpb from releases and double-click to install.
# Download standalone executable (no .NET runtime required)
# From: https://github.com/sbroenne/mcp-server-excel/releases/latest
# Extract excelcli.exe to a directory in PATH
# OR install via .NET tool (requires .NET 10 runtime)
dotnet tool install --global Sbroenne.ExcelMcp.CLI
# Verify installation
excelcli --version
# Register plugin marketplace (one-time)
copilot plugin marketplace add sbroenne/mcp-server-excel-plugins
# Install CLI skill (for coding agents)
copilot plugin install excel-cli@mcp-server-excel-plugins
# Install MCP server skill (for conversational AI)
copilot plugin install excel-mcp@mcp-server-excel-plugins
# Download mcp-excel.exe from releases
# Add to PATH, then configure your MCP client:
# Auto-configure for coding agents (requires Node.js)
npx add-mcp "mcp-excel" --name excel-mcp
# OR manually add to MCP client config (e.g., Claude Desktop)
# %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"excel-mcp": {
"command": "mcp-excel.exe"
}
}
}
| Interface | Best For | Token Usage |
|---|---|---|
CLI (excelcli) | Coding agents (Copilot, Cursor), scripting | 64% fewer tokens |
| MCP Server | Conversational AI (Claude Desktop, VS Code Chat) | More tokens, better tool discovery |
Why CLI is better for coding agents:
All CLI commands follow the pattern:
excelcli <category> <operation> [options]
# File management
excelcli file create --path "Sales.xlsx"
excelcli file open --path "Sales.xlsx"
excelcli file close --save
# Range operations
excelcli range set-values --range "A1:B2" --values "[[\"Name\",\"Age\"],[\"Alice\",30]]"
excelcli range get-values --range "A1:C10"
excelcli range set-formulas --range "D2:D10" --formulas "=B2*C2"
# Table operations
excelcli table create --range "A1:D10" --name "SalesData" --has-headers
excelcli table add-column --table "SalesData" --name "Total" --formula "=[@Quantity]*[@Price]"
excelcli table apply-filter --table "SalesData" --column "Region" --values "[\"West\",\"East\"]"
# PivotTable operations
excelcli pivottable create --source-range "A1:D100" --destination "Sheet2!A1" --name "SalesPivot"
excelcli pivottable add-row-field --pivottable "SalesPivot" --field "Product"
excelcli pivottable add-data-field --pivottable "SalesPivot" --field "Sales" --function "Sum"
# Chart operations
excelcli chart create --type "ColumnClustered" --source-range "A1:B10" --destination "Sheet1!E1" --name "SalesChart"
excelcli chart add-series --chart "SalesChart" --name "Q1 Sales" --values "=Sheet1!$B$2:$B$10" --x-values "=Sheet1!$A$2:$A$10"
# Power Query
excelcli powerquery create --name "ImportCSV" --formula "let Source = Csv.Document(File.Contents(\"data.csv\")) in Source"
excelcli powerquery refresh --query "ImportCSV"
excelcli powerquery export-all --output-dir "./queries"
# Data Model / DAX
excelcli datamodel add-measure --table "Sales" --name "TotalRevenue" --formula "SUM(Sales[Amount])"
excelcli datamodel create-relationship --from-table "Orders" --from-column "ProductID" --to-table "Products" --to-column "ProductID"
# VBA
excelcli vba import-module --name "Utils" --code-path "utils.bas"
excelcli vba run-macro --macro "UpdatePrices"
# Formatting
excelcli rangeformat set-font --range "A1:D1" --bold --size 14
excelcli rangeformat set-number-format --range "B2:B10" --format "$#,##0.00"
excelcli rangeformat auto-fit-columns --range "A:D"
# Conditional Formatting
excelcli conditionalformatting add-rule --range "B2:B100" --rule-type "CellValue" --operator "GreaterThan" --formula1 "500" --format-color "Green"
# Slicers
excelcli slicer create --source "SalesData" --field "Region" --destination "Sheet1!F1" --name "RegionSlicer"
# Window Management
excelcli window show
excelcli window hide
excelcli window set-status --message "Processing sales data..."
# Create new workbook
excelcli file create --path "SalesDashboard.xlsx"
# Add sample data
excelcli range set-values --range "A1:D1" --values "[[\"Date\",\"Product\",\"Quantity\",\"Price\"]]"
excelcli range set-values --range "A2:D5" --values "[[\"2024-01-01\",\"Widget\",10,25.50],[\"2024-01-02\",\"Gadget\",5,45.00],[\"2024-01-03\",\"Widget\",8,25.50],[\"2024-01-04\",\"Gadget\",12,45.00]]"
# Convert to table
excelcli table create --range "A1:D5" --name "SalesData" --has-headers
# Add calculated column
excelcli table add-column --table "SalesData" --name "Total" --formula "=[@Quantity]*[@Price]"
# Create PivotTable
excelcli pivottable create --source-table "SalesData" --destination "Sheet2!A1" --name "ProductSummary"
excelcli pivottable add-row-field --pivottable "ProductSummary" --field "Product"
excelcli pivottable add-data-field --pivottable "ProductSummary" --field "Total" --function "Sum"
# Create chart
excelcli chart create --type "ColumnClustered" --pivottable "ProductSummary" --destination "Sheet2!E1" --name "ProductChart"
# Show Excel to see results
excelcli window show
# Save and close
excelcli file save
excelcli file close
# Create Power Query to import CSV
excelcli powerquery create --name "ImportSales" --formula "let Source = Csv.Document(File.Contents(\"C:\\Data\\sales.csv\"), [Delimiter=\",\", Encoding=65001, Headers=true]), ChangedType = Table.TransformColumnTypes(Source, {{\"Date\", type date}, {\"Amount\", type number}}) in ChangedType" --load-to-worksheet "RawData"
# Create another query to transform data
excelcli powerquery create --name "CleanSales" --formula "let Source = ImportSales, Filtered = Table.SelectRows(Source, each [Amount] > 0) in Filtered" --load-to-data-model
# Add DAX measure
excelcli datamodel add-measure --table "CleanSales" --name "TotalRevenue" --formula "SUM(CleanSales[Amount])"
# Refresh all queries
excelcli powerquery refresh-all
# Export M code for version control
excelcli powerquery export-all --output-dir "./power-queries"
using System.Diagnostics;
void GenerateMonthlyReport(string dataPath, string outputPath)
{
// Open template
RunExcelCli($"file open --path \"{dataPath}\"");
// Refresh all connections
RunExcelCli("connection refresh-all");
// Update calculations
RunExcelCli("calculation calculate-all");
// Format report
RunExcelCli("rangeformat set-font --range \"A1:Z1\" --bold --color \"White\"");
RunExcelCli("rangeformat set-fill --range \"A1:Z1\" --color \"DarkBlue\"");
RunExcelCli("rangeformat auto-fit-columns --range \"A:Z\"");
// Apply conditional formatting to revenue column
RunExcelCli("conditionalformatting add-rule --range \"F2:F1000\" --rule-type \"ColorScale\" --min-color \"Red\" --max-color \"Green\"");
// Create summary pivot
RunExcelCli("pivottable create --source-range \"A1:Z1000\" --destination \"Summary!A1\" --name \"MonthlySummary\"");
RunExcelCli("pivottable add-row-field --pivottable \"MonthlySummary\" --field \"Department\"");
RunExcelCli("pivottable add-data-field --pivottable \"MonthlySummary\" --field \"Revenue\" --function \"Sum\"");
// Add chart
RunExcelCli("chart create --type \"ColumnClustered\" --pivottable \"MonthlySummary\" --destination \"Summary!E1\" --name \"DeptRevenue\"");
// Save as new file
RunExcelCli($"file save --path \"{outputPath}\"");
RunExcelCli("file close");
}
void RunExcelCli(string args)
{
var psi = new ProcessStartInfo
{
FileName = "excelcli",
Arguments = args,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true
};
using var process = Process.Start(psi);
process.WaitForExit();
if (process.ExitCode != 0)
{
var error = process.StandardError.ReadToEnd();
throw new Exception($"ExcelCli failed: {error}");
}
}
// Usage
GenerateMonthlyReport("C:\\Reports\\Template.xlsx", "C:\\Reports\\January2024.xlsx");
# Export existing VBA modules
excelcli vba export-module --name "DataValidation" --output-path "./vba/DataValidation.bas"
excelcli vba export-module --name "Utilities" --output-path "./vba/Utilities.bas"
# Later: Import updated modules
excelcli vba import-module --name "DataValidation" --code-path "./vba/DataValidation.bas" --replace
# Run macro
excelcli vba run-macro --macro "DataValidation.ValidateAllSheets"
# List all VBA modules
excelcli vba list-modules
ExcelMcp requires no special configuration files. Key behaviors:
File Paths:
Excel Instance:
window show to watch AI work in real-timewindow hide for headless automationEnvironment Variables:
# Optional: Customize Excel COM instance behavior
# (Most users don't need these)
EXCEL_VISIBLE=true # Start Excel visible by default
EXCEL_SCREENUPDATING=false # Disable screen updates for performance
# Create table from range
excelcli table create --range "A1:F100" --name "SalesData" --has-headers
# Add slicer for interactive filtering
excelcli slicer create --source "SalesData" --field "Region" --destination "Sheet1!H1"
# Create pivot from table
excelcli pivottable create --source-table "SalesData" --destination "Sheet2!A1" --name "Summary"
excelcli pivottable add-row-field --pivottable "Summary" --field "Product"
excelcli pivottable add-column-field --pivottable "Summary" --field "Quarter"
excelcli pivottable add-data-field --pivottable "Summary" --field "Sales" --function "Sum"
# Chart from pivot
excelcli chart create --type "ColumnClustered" --pivottable "Summary" --destination "Sheet2!F1"
# Import data to Data Model
excelcli powerquery create --name "Sales" --formula "let Source = Csv.Document(File.Contents(\"C:\\Data\\sales.csv\")) in Source" --load-to-data-model
excelcli powerquery create --name "Products" --formula "let Source = Csv.Document(File.Contents(\"C:\\Data\\products.csv\")) in Source" --load-to-data-model
# Create relationship
excelcli datamodel create-relationship --from-table "Sales" --from-column "ProductID" --to-table "Products" --to-column "ProductID"
# Add measures
excelcli datamodel add-measure --table "Sales" --name "TotalRevenue" --formula "SUM(Sales[Amount])"
excelcli datamodel add-measure --table "Sales" --name "AvgOrderValue" --formula "DIVIDE([TotalRevenue], COUNTROWS(Sales))"
# Format multiple header rows in one command
excelcli rangeformat set-font --range "A1:G1,A12:G12,A24:G24" --bold --size 12
# Apply number formats
excelcli rangeformat set-number-format --range "B2:B100" --format "$#,##0.00" # Currency
excelcli rangeformat set-number-format --range "C2:C100" --format "0.0%" # Percentage
excelcli rangeformat set-number-format --range "D2:D100" --format "mm/dd/yyyy" # Date
# Auto-fit all columns
excelcli rangeformat auto-fit-columns --range "A:Z"
Issue: "Excel is already open with another file"
Solution:
# Close all Excel files first
excelcli file close --no-save
# Or manually close Excel application
Issue: "Failed to create Excel COM object"
Solution:
Issue: "Power Query syntax error"
Solution:
# Use absolute paths in M formulas
# BAD: File.Contents("data.csv")
# GOOD: File.Contents("C:\\Data\\data.csv")
# Escape quotes in JSON formulas
excelcli powerquery create --name "Test" --formula "let Source = \"Hello\" in Source"
Issue: "Range 'Sheet1!A1:B10' does not exist"
Solution:
# Ensure worksheet exists first
excelcli worksheet create --name "Sheet1"
# Use correct worksheet reference
excelcli range set-values --range "Sheet1!A1:B2" --values "[[1,2],[3,4]]"
Issue: "Invalid JSON in --values argument"
Solution:
# Escape quotes properly in PowerShell/CMD
excelcli range set-values --range "A1:B2" --values "[[\"Name\",\"Age\"],[\"Alice\",30]]"
# Or use single quotes (PowerShell)
excelcli range set-values --range 'A1:B2' --values '[["Name","Age"],["Alice",30]]'
Issue: Slow automation for large datasets
Solution:
# Disable screen updating
excelcli window hide
# Set calculation to manual
excelcli calculation set-mode --mode "Manual"
# Do your work...
# Re-enable when done
excelcli calculation calculate-all
excelcli calculation set-mode --mode "Automatic"
excelcli window show
When using the MCP server (not CLI), these are the available tools:
file - Create, open, save, close workbooksworksheet - Create, delete, rename, move sheetsrange - Get/set values, formulas, named rangesrange_format - Font, fill, borders, alignment, number formatsrange_validation - Data validation rulesrange_protection - Protect/unprotect rangestable - Create, modify, filter Excel tablespivottable - Create, configure PivotTablespivottable_field - Manage PivotTable fieldspivottable_calculated - Add calculated fields/itemschart - Create, configure chartschart_series - Manage chart data seriespowerquery - Create, refresh, export Power Query queriesdatamodel - Manage Data Model tables, relationshipsdatamodel_dax - Create DAX measuresvba - Import, export, run VBA macrosconnection - Manage data connectionsslicer - Create, configure slicersconditionalformatting - Add/clear formatting rulesscreenshot - Capture ranges/sheets as PNGwindow - Show/hide Excel, set status messagescalculation - Get/set calculation mode, trigger recalcEach tool has multiple operations. See FEATURES.md for complete reference.
Remember: ExcelMcp controls the actual Excel application via COM. Always close Excel files before starting automation, and use window show to watch AI work in real-time during development.
Policy-centered context budget layer that turns sprawling codebases into compact, high-signal context for AI coding agents using symbol graphs and precision tools
Control and automate Slay the Spire 2 gameplay through REST API or MCP server for AI agents
MCP server for browser automation using natural language through kogiQA, enabling AI agents to interact with web pages without selectors
Professional browser automation for Claude Code, Codex, and MCP clients powered by DrissionPage MCP Server
MCP server for Yuque (语雀) knowledge base - search, create, and manage documents through AI assistants
MCP server connecting AI assistants to Shopify Admin GraphQL API for products, orders, customers, inventory, and metafields management