1.16.0pypi · excel-mcp-server-fastmcp · current release
Observed 2026-08-22T11:40:44.871Z using mcpSecurity-inventory. Status: succeeded. Negotiated protocol: 2025-06-18.
{
"experimental": {},
"prompts": {
"listChanged": false
},
"resources": {
"subscribe": false,
"listChanged": false
},
"tools": {
"listChanged": false
}
}| Tool | Category | Annotations | Risk |
|---|---|---|---|
excel_compare_files逐单元格比较两个Excel文件的所有工作表差异(单元格级对比)。
与 excel_compare_sheets 的区别:本工具逐个单元格比对值,返回每个不同单元格的位置和前后值。
适用于:精确找出哪些单元格被修改了。
Args:
file1_path: 第一个文件路径(基准/旧版本)
file2_path: 第二个文件路径(对比/新版本)
Input schema{
"properties": {
"file1_path": {
"title": "File1 Path",
"type": "string"
},
"file2_path": {
"title": "File2 Path",
"type": "string"
}
},
"required": [
"file1_path",
"file2_path"
],
"title": "excel_compare_filesArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_compare_filesDictOutput",
"type": "object"
} | — | — · — | — |
excel_compare_sheets按ID列比较两个工作表的行级差异(对象级对比:新增/删除/修改)。
与 excel_compare_files 的区别:本工具按ID匹配行,返回行级别的变更摘要(新增/删除/修改了哪些行)。
适用于:比较两个版本的配置表,了解数据变动概况。
Args:
file1_path: 第一个文件路径(基准/旧版本)
sheet1_name: 第一个工作表名称
file2_path: 第二个文件路径(对比/新版本)
sheet2_name: 第二个工作表名称
id_column: ID列名(字符串)或列索引(从1开始的整数),默认为1表示第1列
header_row: 表头行号,默认为1
Input schema{
"properties": {
"file1_path": {
"title": "File1 Path",
"type": "string"
},
"sheet1_name": {
"title": "Sheet1 Name",
"type": "string"
},
"file2_path": {
"title": "File2 Path",
"type": "string"
},
"sheet2_name": {
"title": "Sheet2 Name",
"type": "string"
},
"id_column": {
"anyOf": [
{
"type": "integer"
},
{
"type": "string"
}
],
"default": 1,
"title": "Id Column"
},
"header_row": {
"default": 1,
"title": "Header Row",
"type": "integer"
}
},
"required": [
"file1_path",
"sheet1_name",
"file2_path",
"sheet2_name"
],
"title": "excel_compare_sheetsArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_compare_sheetsDictOutput",
"type": "object"
} | — | — · — | — |
excel_copy_sheet复制工作表(含数据和格式)。新工作表在同一文件内创建。
Args:
file_path: Excel文件路径
source_name: 源工作表名称
new_name: 新工作表名称,默认为None(自动命名为"源名_副本")
index: 插入位置索引(从0开始),默认为None(追加到末尾)Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"source_name": {
"title": "Source Name",
"type": "string"
},
"new_name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "New Name"
},
"index": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Index"
}
},
"required": [
"file_path",
"source_name"
],
"title": "excel_copy_sheetArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_copy_sheetDictOutput",
"type": "object"
} | — | — · — | — |
excel_create_backup为Excel文件创建备份。备份存放在同级backup目录。
Args:
file_path: Excel文件路径
backup_dir: 备份目录路径,默认为None表示同级backup目录
Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"backup_dir": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Backup Dir"
}
},
"required": [
"file_path"
],
"title": "excel_create_backupArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_create_backupDictOutput",
"type": "object"
} | — | — · — | — |
excel_create_chart在工作表中创建图表。chart_type: line/bar/column/pie/scatter/area等。支持'column'作为'bar'的别名。
Args:
file_path: Excel文件路径
sheet_name: 工作表名称
chart_type: 图表类型
data_range: 数据范围
title: 图表标题,默认为空字符串
chart_name: 图表名称,默认为空字符串
position: 图表位置,默认为"B15"
Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"sheet_name": {
"title": "Sheet Name",
"type": "string"
},
"chart_type": {
"title": "Chart Type",
"type": "string"
},
"data_range": {
"title": "Data Range",
"type": "string"
},
"title": {
"default": "",
"title": "Title",
"type": "string"
},
"chart_name": {
"default": "",
"title": "Chart Name",
"type": "string"
},
"position": {
"default": "B15",
"title": "Position",
"type": "string"
}
},
"required": [
"file_path",
"sheet_name",
"chart_type",
"data_range"
],
"title": "excel_create_chartArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_create_chartDictOutput",
"type": "object"
} | — | — · — | — |
excel_create_file创建新Excel文件。可指定初始工作表名称列表。
Args:
file_path: Excel文件路径
sheet_names: 初始工作表名称列表,默认为None
Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"sheet_names": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"title": "Sheet Names"
}
},
"required": [
"file_path"
],
"title": "excel_create_fileArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_create_fileDictOutput",
"type": "object"
} | — | — · — | — |
excel_create_sheet创建新工作表。可指定插入位置index(从0开始,0=最前面)。
Args:
file_path: Excel文件路径
sheet_name: 新工作表名称
index: 插入位置索引(从0开始,默认为None表示追加到末尾)
Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"sheet_name": {
"title": "Sheet Name",
"type": "string"
},
"index": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Index"
}
},
"required": [
"file_path",
"sheet_name"
],
"title": "excel_create_sheetArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_create_sheetDictOutput",
"type": "object"
} | — | — · — | — |
excel_delete_columns删除指定位置开始的列。column_index从1开始。
Args:
file_path: Excel文件路径
sheet_name: 工作表名称
column_index: 起始列索引(从1开始)
count: 删除的列数,默认为1Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"sheet_name": {
"title": "Sheet Name",
"type": "string"
},
"column_index": {
"title": "Column Index",
"type": "integer"
},
"count": {
"default": 1,
"title": "Count",
"type": "integer"
}
},
"required": [
"file_path",
"sheet_name",
"column_index"
],
"title": "excel_delete_columnsArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_delete_columnsDictOutput",
"type": "object"
} | — | — · — | — |
excel_delete_querySQL删除数据。必须指定WHERE条件。
示例::
DELETE FROM Raids WHERE Score < 8000
DELETE FROM Raids WHERE _ROW_NUMBER_ IN (3, 5, 7)
Args:
file_path: Excel文件路径
delete_expression: DELETE语句
dry_run: 是否仅预览不实际删除,默认为False
Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"delete_expression": {
"title": "Delete Expression",
"type": "string"
},
"dry_run": {
"default": false,
"title": "Dry Run",
"type": "boolean"
}
},
"required": [
"file_path",
"delete_expression"
],
"title": "excel_delete_queryArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_delete_queryDictOutput",
"type": "object"
} | — | — · — | — |
excel_delete_rows按行号删除行。row_index从1开始(第1行前删除传1)。
⚠️ 按条件删除请用 excel_delete_query(SQL DELETE FROM ... WHERE ...)
Args:
file_path: Excel文件路径
sheet_name: 工作表名称
row_index: 要删除的起始行索引(从1开始,在该行位置删除)
count: 删除的行数,默认为1
Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"sheet_name": {
"title": "Sheet Name",
"type": "string"
},
"row_index": {
"title": "Row Index",
"type": "integer"
},
"count": {
"default": 1,
"title": "Count",
"type": "integer"
}
},
"required": [
"file_path",
"sheet_name",
"row_index"
],
"title": "excel_delete_rowsArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_delete_rowsDictOutput",
"type": "object"
} | — | — · — | — |
excel_delete_sheet删除指定工作表。
Args:
file_path: Excel文件路径
sheet_name: 要删除的工作表名称
Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"sheet_name": {
"title": "Sheet Name",
"type": "string"
}
},
"required": [
"file_path",
"sheet_name"
],
"title": "excel_delete_sheetArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_delete_sheetDictOutput",
"type": "object"
} | — | — · — | — |
excel_describe_table📊 **表结构分析**:快速了解表的列名、类型、样本值。
💡 **使用场景**:
• 快速了解表结构 → excel_describe_table(列名+类型+样本值+行数)
• 数据操作前了解表结构 → 避免列名错误
• 需要数据类型和非空统计 → 自动推断类型、非空比例
⚠️ **不推荐用于**:
• 只需表头信息 → 使用 excel_get_headers(更轻量)
• 已知精确坐标读取数据 → 使用 excel_get_range
• 需要筛选/聚合 → 使用 excel_query(SQL引擎)
分析Excel工作表(sheet)结构:列名、数据类型、非空统计、样本数据。
任何数据操作前应先调用此工具了解表结构,避免列名错误。
自动识别双行表头(中文描述+英文字段名)。
Args:
file_path: Excel文件路径
sheet_name: 工作表名称,默认为None表示第一个工作表
Returns:
data.sheet_name: 工作表名称
data.header_type: 表头类型 ("dual"=双行 / "single"=单行)
data.row_count: 数据行数
data.column_count: 列数
data.columns: 列信息列表 [{name, type, description, non_null, sample_values}]
Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"sheet_name": {
"default": null,
"title": "Sheet Name",
"type": "string"
}
},
"required": [
"file_path"
],
"title": "excel_describe_tableArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_describe_tableDictOutput",
"type": "object"
} | — | — · — | — |
excel_export_to_csv将工作表导出为CSV文件。
Args:
file_path: Excel文件路径
output_path: CSV输出路径
sheet_name: 工作表名称,默认为None
encoding: 编码格式,默认为"utf-8"
Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"output_path": {
"title": "Output Path",
"type": "string"
},
"sheet_name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Sheet Name"
},
"encoding": {
"default": "utf-8",
"title": "Encoding",
"type": "string"
}
},
"required": [
"file_path",
"output_path"
],
"title": "excel_export_to_csvArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_export_to_csvDictOutput",
"type": "object"
} | — | — · — | — |
excel_find_last_row查找工作表最后一行。可指定列来找该列最后一个有值的行。追加数据前必用。
Args:
file_path: Excel文件路径
sheet_name: 工作表名称
column: 列名或列索引,默认为None
Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"sheet_name": {
"title": "Sheet Name",
"type": "string"
},
"column": {
"anyOf": [
{
"type": "string"
},
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Column"
}
},
"required": [
"file_path",
"sheet_name"
],
"title": "excel_find_last_rowArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_find_last_rowDictOutput",
"type": "object"
} | — | — · — | — |
excel_format_cells单元格样式统一入口:字体样式 + 合并/拆分 + 边框,一个工具完成所有外观操作。
支持的操作类别(可在单次调用中组合使用):
📝 字体: bold, italic, underline('single'/'double'/'singleAccounting'), strikethrough,
font_size, font_color, font_name
🎨 单元格: bg_color(背景), fill_type(solid/gradient/pattern), gradient_colors, alignment,
wrap_text, text_rotation, indent, shrink_to_fit, number_format
🔗 结构: merge(True=合并), unmerge(True=取消合并)
📦 边框: border_style(thin/thick/double/dotted/dashed) 或 border{left/right/top/bottom+color}
常用示例:
加粗表头: {"bold": True}
蓝底白字+双下划线: {"bg_color": "0000FF", "font_color": "FFFFFF", "underline": "double", "bold": True}
合并+加粗居中: {"merge": True, "bold": True, "alignment": "center"}
删除线+红色背景: {"strikethrough": True, "bg_color": "FFCCCC"}
渐变背景色: {"gradient_colors": ["4472C4", "ED7D31"], "gradient_type": "linear"}
边框(四边不同): {"border": {"top": "medium", "bottom": "thin", "color": "000000"}}
仅合并: {"merge": True}
边框: {"border_style": "thin"}
合并+边框+背景色: {"merge": True, "border_style": "thin", "bg_color": "FFFF00"}
预设样式: preset="header"(等价于 bold + center + bg_color)
⚠️ 合并警告:merge=True 会清除合并区域内非左上角单元格的值!Excel合并后只有左上角单元格保留数据。
例如合并 A1:E1 后,B1~E1 的值会丢失。如需保留数据,请先复制到其他位置或改用加粗+背景色代替合并。
Args:
file_path: Excel文件路径
sheet_name: 工作表名称
cell_range: 单元格范围(如 "A1:C10" 或 "Sheet1!A1:C10",不含!时自动拼接sheet_name)
formatting: 样式配置字典(可同时指定多项,按 merge/unmerge → format → border 顺序执行):
bold/italic/strikethrough: bool
underline: 'single'(默认) | 'double' | 'singleAccounting' | 'doubleAccounting'
font_size: int | font_color/bg_color: str (HEX)
fill_type: 'solid'(默认) | 'gradient' | 'pattern'
gradient_colors: list[str] 渐变色数组(如 ["4472C4", "ED7D31"])
number_format: str | alignment: left/center/right/top/bottom
wrap_text: bool | text_rotation: int(-90~90度) | indent: int
shrink_to_fit: bool
border: dict{left/right/top/bottom/diagonal: style|dict, color: str}
merge: bool (合并单元格) | unmerge: bool (取消合并)
preset: 预设样式名(bold/italic/highlight/header/currency/title/data)
start_cell/end_cell: 可选,替代 cell_range 使用(如 start_cell="A1", end_cell="E1")
Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"sheet_name": {
"title": "Sheet Name",
"type": "string"
},
"cell_range": {
"title": "Cell Range",
"type": "string"
},
"formatting": {
"anyOf": [
{
"additionalProperties": true,
"type": "object"
},
{
"type": "null"
}
],
"default": null,
"title": "Formatting"
},
"preset": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Preset"
}
},
"required": [
"file_path",
"sheet_name",
"cell_range"
],
"title": "excel_format_cellsArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_format_cellsDictOutput",
"type": "object"
} | — | — · — | — |
excel_get_headers📋 **表头信息**:轻量级获取列名(中文+英文)。
💡 **使用场景**:
• 只需表头信息 → excel_get_headers(更轻量)
• 需要双行表头(中文+英文)→ 自动识别
• 获取所有表的表头 → 不传sheet_name参数
⚠️ **不推荐用于**:
• 需要数据类型/样本值 → 使用 excel_describe_table(完整分析)
• 需要筛选/聚合 → 使用 excel_query(SQL引擎)
提取工作表表头信息。支持双行表头(中文描述+英文字段名)。
不传sheet_name获取所有表的表头。
Args:
file_path: Excel文件路径
sheet_name: 工作表名称,默认为None表示获取所有表的表头
header_row: 表头行号,默认为1
max_columns: 最大列数限制,默认为None
Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"sheet_name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Sheet Name"
},
"header_row": {
"default": 1,
"title": "Header Row",
"type": "integer"
},
"max_columns": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Max Columns"
}
},
"required": [
"file_path"
],
"title": "excel_get_headersArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_get_headersDictOutput",
"type": "object"
} | — | — · — | — |
excel_get_range📍 **精确读取**:已知单元格坐标时使用(如A1:C10)。
💡 **使用场景**:
• 已知精确坐标 → excel_get_range(精确读取,如 "Sheet1!A1:C10")
• 需要单元格格式信息 → include_formatting=True
⚠️ **不推荐用于**:
• 需要筛选/聚合/JOIN/排序 → 使用 excel_query(SQL引擎)
• 快速了解表结构 → 使用 excel_describe_table(列名+类型+样本值)
• 只需表头信息 → 使用 excel_get_headers
返回二维CellInfo数组[[{coordinate,value},...],...]。
每个单元格返回 {coordinate: "A1", value: ...},空单元格value为null。
支持include_formatting获取样式信息(额外返回font/fill等字段)。
Args:
file_path: Excel文件路径
cell_range: 单元格范围(如 "A1:C10" 或 "Sheet1!A1:C10",不含!时配合sheet_name使用)
include_formatting: 是否包含格式信息,默认False
sheet_name: 工作表名称(可选,cell_range不含!时自动拼接为 "sheet_name!cell_range")
Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"cell_range": {
"title": "Cell Range",
"type": "string"
},
"include_formatting": {
"default": false,
"title": "Include Formatting",
"type": "boolean"
},
"sheet_name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Sheet Name"
}
},
"required": [
"file_path",
"cell_range"
],
"title": "excel_get_rangeArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_get_rangeDictOutput",
"type": "object"
} | — | — · — | — |
excel_import_from_csv从CSV文件创建Excel工作表。
Args:
csv_path: CSV文件路径
output_path: Excel输出路径
sheet_name: 工作表名称,默认为"Sheet1"
encoding: 编码格式,默认为"utf-8"
has_header: CSV是否有表头,默认为True
Input schema{
"properties": {
"csv_path": {
"title": "Csv Path",
"type": "string"
},
"output_path": {
"title": "Output Path",
"type": "string"
},
"sheet_name": {
"default": "Sheet1",
"title": "Sheet Name",
"type": "string"
},
"encoding": {
"default": "utf-8",
"title": "Encoding",
"type": "string"
},
"has_header": {
"default": true,
"title": "Has Header",
"type": "boolean"
}
},
"required": [
"csv_path",
"output_path"
],
"title": "excel_import_from_csvArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_import_from_csvDictOutput",
"type": "object"
} | — | — · — | — |
excel_insert_columns在指定位置插入空列。column_index从1开始。
Args:
file_path: Excel文件路径
sheet_name: 工作表名称
column_index: 插入位置的列索引(从1开始)
count: 插入的列数,默认为1Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"sheet_name": {
"title": "Sheet Name",
"type": "string"
},
"column_index": {
"title": "Column Index",
"type": "integer"
},
"count": {
"default": 1,
"title": "Count",
"type": "integer"
}
},
"required": [
"file_path",
"sheet_name",
"column_index"
],
"title": "excel_insert_columnsArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_insert_columnsDictOutput",
"type": "object"
} | — | — · — | — |
excel_insert_querySQL插入数据。支持单行/多行INSERT。
示例::
INSERT INTO 技能表 (技能名称, 伤害, 冷却) VALUES ('火球术', 300, 6)
INSERT INTO Raids (RID, CID, Score) VALUES (6, 105, 7000), (7, 106, 8000)
Args:
file_path: Excel文件路径
insert_expression: INSERT语句
dry_run: 是否仅预览不实际写入,默认为False
Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"insert_expression": {
"title": "Insert Expression",
"type": "string"
},
"dry_run": {
"default": false,
"title": "Dry Run",
"type": "boolean"
}
},
"required": [
"file_path",
"insert_expression"
],
"title": "excel_insert_queryArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_insert_queryDictOutput",
"type": "object"
} | — | — · — | — |
excel_insert_rows在指定位置插入空行。row_index从1开始(第1行前插入传1)。
Args:
file_path: Excel文件路径
sheet_name: 工作表名称
row_index: 插入位置的行索引(从1开始,在该行上方插入)
count: 插入的行数,默认为1Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"sheet_name": {
"title": "Sheet Name",
"type": "string"
},
"row_index": {
"title": "Row Index",
"type": "integer"
},
"count": {
"default": 1,
"title": "Count",
"type": "integer"
}
},
"required": [
"file_path",
"sheet_name",
"row_index"
],
"title": "excel_insert_rowsArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_insert_rowsDictOutput",
"type": "object"
} | — | — · — | — |
excel_list_backups列出文件的所有备份版本及时间。
Args:
file_path: Excel文件路径
backup_dir: 备份目录路径,默认为None
Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"backup_dir": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Backup Dir"
}
},
"required": [
"file_path"
],
"title": "excel_list_backupsArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_list_backupsDictOutput",
"type": "object"
} | — | — · — | — |
excel_list_sheets列出Excel文件中的所有工作表名称。查询前先用此工具确认工作表存在。
Args:
file_path: Excel文件路径
Returns:
Dict[str, Any]: 包含工作表列表的字典,结构为 {"sheets": ["sheet1", "sheet2"], "success": bool}
Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
}
},
"required": [
"file_path"
],
"title": "excel_list_sheetsArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_list_sheetsDictOutput",
"type": "object"
} | — | — · — | — |
excel_query🔥 **首选工具**:所有数据查询/分析任务,优先使用此工具。
💡 **使用场景**:
• 需要筛选/聚合/JOIN/排序 → excel_query(SQL引擎,批量分析首选)
• 复杂条件筛选 → WHERE, LIKE, IN, BETWEEN, 子查询
• 聚合统计 → COUNT, SUM, AVG, MAX, MIN, GROUP BY, HAVING
• 多表关联 → 5种JOIN类型,支持跨文件查询
• 窗口函数 → ROW_NUMBER, RANK, DENSE_RANK
• 字符串函数 → UPPER, LOWER, TRIM, LENGTH, CONCAT, REPLACE, SUBSTRING
⚠️ **不推荐用于**:
• 已知精确坐标(如A1:C10)→ 使用 excel_get_range
• 只需表头信息 → 使用 excel_get_headers 或 excel_describe_table
query_expression: SELECT * FROM 技能表 WHERE 伤害>100 | GROUP BY | JOIN ON
Args:
file_path: Excel文件路径
query_expression: SQL查询语句
include_headers: 是否包含表头,默认为True
output_format: 输出格式,默认为"table"
Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"query_expression": {
"title": "Query Expression",
"type": "string"
},
"include_headers": {
"default": true,
"title": "Include Headers",
"type": "boolean"
},
"output_format": {
"default": "table",
"title": "Output Format",
"type": "string"
}
},
"required": [
"file_path",
"query_expression"
],
"title": "excel_queryArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_queryDictOutput",
"type": "object"
} | — | — · — | — |
excel_rename_column修改表头(列名)。只改header_row指定的行。
Args:
file_path: Excel文件路径
sheet_name: 工作表名称
old_header: 原列名
new_header: 新列名
header_row: 表头行号,默认为1
Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"sheet_name": {
"title": "Sheet Name",
"type": "string"
},
"old_header": {
"title": "Old Header",
"type": "string"
},
"new_header": {
"title": "New Header",
"type": "string"
},
"header_row": {
"default": 1,
"title": "Header Row",
"type": "integer"
}
},
"required": [
"file_path",
"sheet_name",
"old_header",
"new_header"
],
"title": "excel_rename_columnArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_rename_columnDictOutput",
"type": "object"
} | — | — · — | — |
excel_rename_sheet重命名工作表。
Args:
file_path: Excel文件路径
old_name: 原工作表名称
new_name: 新工作表名称
Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"old_name": {
"title": "Old Name",
"type": "string"
},
"new_name": {
"title": "New Name",
"type": "string"
}
},
"required": [
"file_path",
"old_name",
"new_name"
],
"title": "excel_rename_sheetArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_rename_sheetDictOutput",
"type": "object"
} | — | — · — | — |
excel_restore_backup从备份文件恢复Excel。target_path不传则覆盖原文件。
Args:
backup_path: 备份文件路径
target_path: 目标文件路径,默认为None表示覆盖原文件
Input schema{
"properties": {
"backup_path": {
"title": "Backup Path",
"type": "string"
},
"target_path": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Target Path"
}
},
"required": [
"backup_path"
],
"title": "excel_restore_backupArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_restore_backupDictOutput",
"type": "object"
} | — | — · — | — |
excel_run_python🐍 直接执行Python代码操作Excel文件,适用于循环/复杂逻辑/重复操作。
当SQL无法表达你的逻辑(如逐行循环、复杂条件、自定义函数)时,用此工具直接写Python代码。
比多次调用MCP工具更节省token。直接调用现有API,file_path已预绑定。
可用变量:
- file_path: 当前Excel文件路径
- sheet_name: 指定的工作表名称
- query(sql): 执行SQL查询,直接返回 [[headers], [row1], ...]
- update(sql, dry_run=False): 执行SQL更新(= excel_update_query)
- insert(sql): 执行SQL插入(= excel_insert_query)
- delete(sql, dry_run=False): 执行SQL删除(= excel_delete_query)
- ExcelOperations: 完整Excel操作类(get_range, update_range, upsert_row等)
代码示例:
# SQL查询 - 直接拿到数据行
rows = query("SELECT * FROM 装备 WHERE Price > 100")
headers = rows[0]
for row in rows[1:]:
print(row[headers.index("Name")])
# 循环+SQL组合
rows = query("SELECT ID, Price FROM 装备")
for row in rows[1:]:
update(f"UPDATE 装备 SET Price = {row[1] * 1.1} WHERE ID = {row[0]}")
# 调用ExcelOperations
ExcelOperations.upsert_row(file_path, "装备", "ID", 1, {"Price": 999})
Args:
file_path: Excel文件路径
code: Python代码(支持表达式和多行语句)
sheet_name: 工作表名称(默认活跃工作表)
timeout: 超时秒数,默认30,最大120
Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"code": {
"title": "Code",
"type": "string"
},
"sheet_name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Sheet Name"
},
"timeout": {
"default": 30,
"title": "Timeout",
"type": "integer"
}
},
"required": [
"file_path",
"code"
],
"title": "excel_run_pythonArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_run_pythonDictOutput",
"type": "object"
} | — | — · — | — |
excel_search在Excel中搜索匹配pattern的单元格。
Args:
file_path: Excel文件路径
pattern: 搜索模式(文本或正则,use_regex=None时自动检测)
sheet_name: 工作表名称,默认搜索全部
case_sensitive: 区分大小写,默认False
whole_word: 全词匹配,默认False
use_regex: None=自动检测(含特殊字符时启用),True/False=强制
cell_range: 搜索范围(如 "A1:C10" 或 "Sheet1!A1:C10",不含!时配合sheet_name使用)
Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"pattern": {
"title": "Pattern",
"type": "string"
},
"sheet_name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Sheet Name"
},
"case_sensitive": {
"default": false,
"title": "Case Sensitive",
"type": "boolean"
},
"whole_word": {
"default": false,
"title": "Whole Word",
"type": "boolean"
},
"use_regex": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": null,
"title": "Use Regex"
},
"cell_range": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Cell Range"
}
},
"required": [
"file_path",
"pattern"
],
"title": "excel_searchArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_searchDictOutput",
"type": "object"
} | — | — · — | — |
excel_search_directory在目录下所有Excel文件中搜索内容。
Args:
directory_path: 搜索目录路径
pattern: 搜索模式(文本或正则)
recursive: 递归子目录,默认True
file_extensions: 扩展名过滤,如 [".xlsx", ".xls"]
max_files: 最大搜索文件数
case_sensitive: 区分大小写,默认False
whole_word: 全词匹配,默认False
use_regex: None=自动检测,True/False=强制
Input schema{
"properties": {
"directory_path": {
"title": "Directory Path",
"type": "string"
},
"pattern": {
"title": "Pattern",
"type": "string"
},
"recursive": {
"default": true,
"title": "Recursive",
"type": "boolean"
},
"file_extensions": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"title": "File Extensions"
},
"max_files": {
"default": 100,
"title": "Max Files",
"type": "integer"
},
"case_sensitive": {
"default": false,
"title": "Case Sensitive",
"type": "boolean"
},
"whole_word": {
"default": false,
"title": "Whole Word",
"type": "boolean"
},
"use_regex": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": null,
"title": "Use Regex"
}
},
"required": [
"directory_path",
"pattern"
],
"title": "excel_search_directoryArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_search_directoryDictOutput",
"type": "object"
} | — | — · — | — |
excel_set_column_width设置列宽(字符单位)。Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"sheet_name": {
"title": "Sheet Name",
"type": "string"
},
"column_index": {
"title": "Column Index",
"type": "integer"
},
"width": {
"title": "Width",
"type": "number"
},
"count": {
"default": 1,
"title": "Count",
"type": "integer"
}
},
"required": [
"file_path",
"sheet_name",
"column_index",
"width"
],
"title": "excel_set_column_widthArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_set_column_widthDictOutput",
"type": "object"
} | — | — · — | — |
excel_set_formula在单元格写入Excel公式。
Args:
file_path: Excel文件路径
sheet_name: 工作表名称
cell_address: 单元格地址,如"A1"
formula: Excel公式,以等号开头
Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"sheet_name": {
"title": "Sheet Name",
"type": "string"
},
"cell_address": {
"title": "Cell Address",
"type": "string"
},
"formula": {
"title": "Formula",
"type": "string"
}
},
"required": [
"file_path",
"sheet_name",
"cell_address",
"formula"
],
"title": "excel_set_formulaArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_set_formulaDictOutput",
"type": "object"
} | — | — · — | — |
excel_set_row_height设置行高(磅值)。Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"sheet_name": {
"title": "Sheet Name",
"type": "string"
},
"row_index": {
"title": "Row Index",
"type": "integer"
},
"height": {
"title": "Height",
"type": "number"
},
"count": {
"default": 1,
"title": "Count",
"type": "integer"
}
},
"required": [
"file_path",
"sheet_name",
"row_index",
"height"
],
"title": "excel_set_row_heightArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_set_row_heightDictOutput",
"type": "object"
} | — | — · — | — |
excel_update_query🔥 **批量修改首选**:按条件批量修改多行数据。
💡 **使用场景**:
• 批量修改多行(改10行以上/按条件改)→ excel_update_query(SQL UPDATE)
• 需要计算表达式 → SET 血量=血量*2
• 需要预览变更 → dry_run=True
• 条件复杂 → WHERE 等级>5 AND 稀有度='传说'
⚠️ **不推荐用于**:
• 🔴 精确覆盖指定区域(知道具体A1:C10)→ 使用 excel_update_range
• 按ID改单行(只改2-3个字段)→ 使用 excel_upsert_row(更安全)
SQL批量修改。dry_run=True预览变更不实际写入。
示例::
UPDATE 技能表 SET 伤害=200 WHERE 等级>=5
UPDATE LootList SET PropType='主武器' WHERE _ROW_NUMBER_ IN (11,21,36)
UPDATE 数据表 SET 状态='已处理' WHERE _ROW_NUMBER_ BETWEEN 10 AND 50
行号支持(_ROW_NUMBER_):
在UPDATE的WHERE条件中可使用 _ROW_NUMBER_ 虚拟列,基于Excel数据行号(不含表头)精确定位行。
适用于:有重复记录无法用字段值唯一确定行的场景。
注意:_ROW_NUMBER_ 仅在UPDATE中可用,SELECT查询暂不支持。
不允许对 _ROW_NUMBER_ 本身执行SET操作。
Args:
file_path: Excel文件路径
update_expression: UPDATE语句
dry_run: 是否仅预览不实际写入,默认为False
Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"update_expression": {
"title": "Update Expression",
"type": "string"
},
"dry_run": {
"default": false,
"title": "Dry Run",
"type": "boolean"
}
},
"required": [
"file_path",
"update_expression"
],
"title": "excel_update_queryArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_update_queryDictOutput",
"type": "object"
} | — | — · — | — |
excel_update_range📍 **精确坐标写入**:知道具体单元格范围时使用。
💡 **使用场景**:
• 🔴 精确覆盖指定区域(知道具体A1:C10)→ excel_update_range
• 🟢 安全追加数据 → 先 find_last_row → 再 update_range(..., insert_mode=True)
• 🔴 直接覆盖数据 → update_range(..., insert_mode=False)【默认,危险】
⚠️ **不推荐用于**:
• 批量修改多行(改10行以上/按条件改)→ 使用 excel_update_query(SQL UPDATE)
• 按ID改单行(知道 key_column + key_value)→ 使用 excel_upsert_row
⚠️ **重要**:默认为覆盖模式(insert_mode=False),会直接替换目标区域数据!
如需保留原有数据并插入新行,必须显式设置 insert_mode=True
Args:
file_path: Excel文件路径
cell_range: 单元格范围(如 "A1:C10" 或 "Sheet1!A1:C10",不含!时配合sheet_name使用)
data: 要写入的数据,二维数组格式 [[row1], [row2], ...]
preserve_formulas: 是否保留已有公式不被覆盖,默认True
insert_mode: False=覆盖模式(默认,直接替换) | True=插入模式(原有数据下移)
sheet_name: 工作表名称(可选,cell_range不含!时自动拼接为 "sheet_name!cell_range")
Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"cell_range": {
"title": "Cell Range",
"type": "string"
},
"data": {
"items": {
"items": {},
"type": "array"
},
"title": "Data",
"type": "array"
},
"preserve_formulas": {
"default": true,
"title": "Preserve Formulas",
"type": "boolean"
},
"insert_mode": {
"default": false,
"title": "Insert Mode",
"type": "boolean"
},
"sheet_name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Sheet Name"
}
},
"required": [
"file_path",
"cell_range",
"data"
],
"title": "excel_update_rangeArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_update_rangeDictOutput",
"type": "object"
} | — | — · — | — |
excel_upsert_row👍 **按ID更新单行首选**:知道key_column+key_value时使用。
💡 **使用场景**:
• 按ID改单行(知道 key_column + key_value)→ excel_upsert_row
• 只改2-3个字段、dict传参方便 → 更安全
• 需要幂等操作(行不存在自动插入)
⚠️ **不推荐用于**:
• 批量修改多行 → 使用 excel_update_query(SQL UPDATE)
• 精确覆盖指定区域 → 使用 excel_update_range
✅ **优点**:不会误改其他行、行不存在自动插入、参数自文档化、双行表头兼容
按key_column+key_value查找行,存在则更新,不存在则插入。
Args:
file_path: Excel文件路径
sheet_name: 工作表名称
key_column: 键列名
key_value: 键值
updates: 要更新的字段字典(如 {"伤害": 200, "冷却": 5})
header_row: 表头行号,默认为1
Input schema{
"properties": {
"file_path": {
"title": "File Path",
"type": "string"
},
"sheet_name": {
"title": "Sheet Name",
"type": "string"
},
"key_column": {
"title": "Key Column",
"type": "string"
},
"key_value": {
"title": "Key Value"
},
"updates": {
"additionalProperties": true,
"title": "Updates",
"type": "object"
},
"header_row": {
"default": 1,
"title": "Header Row",
"type": "integer"
}
},
"required": [
"file_path",
"sheet_name",
"key_column",
"key_value",
"updates"
],
"title": "excel_upsert_rowArguments",
"type": "object"
}Output schema{
"additionalProperties": true,
"title": "excel_upsert_rowDictOutput",
"type": "object"
} | — | — · — | — |