CtrlK
BlogDocsLog inGet started
Tessl Logo
SkillPublic

excel_diff

比对两份 Excel 表格的差异,按位置或按主键找出修改、新增、删除的行,可导出差异表。当用户提到对比 Excel、Excel 差异、两份表格有什么不同、核对表格时使用。

Invalid
This skill can't be scored yet
Validation errors are blocking scoring. Review and fix them to unlock Quality, Impact and Security scores. See what needs fixing →
SKILL.md
Quality
Evals
Security

excel_diff Skill

比对两份 Excel,输出单元格级差异,可导出差异表

功能描述

把两份 Excel 的同一张工作表做对比,返回每个变化的单元格、新增行、删除行和表头变化。 支持两种模式:按行号逐格比对(适合行顺序固定的表),或按主键配对后再比对 (适合行顺序会变、但每行有唯一编号的表)。

所属分类

skills/excel/excel_diff/

调用方式

from skills.excel import excel_diff

excel_diff(
    before_path='上周报表.xlsx',
    after_path='本周报表.xlsx',
    key_column='订单号',
)

参数说明

参数类型必填默认值说明
before_pathstr是-变更前的 Excel 路径
after_pathstr是-变更后的 Excel 路径
sheet_namestr否None工作表名,默认取第一个
key_columnstr否None主键列名;指定后按主键配对行
ignore_casebool否False文本比较是否忽略大小写
output_pathstr否None差异表输出路径,指定后写出 .xlsx

返回值

dict,包含 mode、sheet、header、summary、changes、added_rows、 removed_rows、output_path 八个键。summary 中的 identical 表示两份表是否完全一致。

使用示例

from skills.excel import excel_diff

result = excel_diff('v1.xlsx', 'v2.xlsx', key_column='编号', output_path='差异.xlsx')
print(result['summary'])
for item in result['changes']:
    print(item['key'], item['column'], item['before'], '->', item['after'])

原始函数

contributors/my12yyds/excel_diff.py

Repository

CoderWanFeng/python-office

Path

skills/excel/excel_diff/SKILL.md

Last updated
First committed

Is this your skill?

If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.