利用Git Diff比较Excel-推荐一款小工具

Posted zhangmike

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了利用Git Diff比较Excel-推荐一款小工具相关的知识,希望对你有一定的参考价值。

PowerShell DiffExcel is an open-source and text-based tool to compare excel, it supports Git diff.【前言】ExcelBDD把Excel存储到Git(参见ExcelBDD Guideline By Java Example实现Excel BDD的三部曲),多位网友担心Excel文件是二进制,Git本身不能Diff,出现冲突难以解决,难以追溯。本人工作环境里面有“Spreadsheet Compare”,可以图形化比对出差异,而且流程上规避了Excel版本冲突(参见与Confluence联动,ExcelBDD让业务人员参与到自动化测试),因此之前一直没有处理此问题。

最新推进ExcelBDD中,需要给出Excel Diff的解决方案,经过几番搜索和尝试,搜到不少,但竟然没有发现免费好用的小工具,其中意外的是Spreadsheet Compare竟然不属于Office365。

于是这个周末花点时间开发了这个小工具,分享给大家。

PowerShell DiffExcel is an open-source and text-based tool to compare excel, it supports Git diff.

Pre-Requirement

  • Microsoft Excel

  • PowerShell which is pre-installed in Windows10

Install

  1. Open PowerShell

  2. execute Install-Script -Name DiffExcel
    2.1 if updating, execute Update-Script -Name DiffExcel

Direct Usage

In PowerShell, use the below syntax:
DiffExcel OldExcelFilePath NewExcelFilePath
e.g. 

DiffExcel E:\\Code\\ExcelBDD\\DiffExcel\\Test\\OldFile.xlsx  E:\\Code\\ExcelBDD\\DiffExcel\\Test\\NewFile.xlsx

Config Git Diff

Prepare a Diff bat file

PowerShell -ExecutionPolicy Unrestricted -Command DiffExcel %2 %5

save this bat file to somewhere on your computer, e.g. E:/Code/ExcelBDD/DiffExcel/DiffExcel.bat

Set .git/config

Edit the .git/config file in your repository and amend the following:

[diff "excel"]
	command = E:/Code/ExcelBDD/DiffExcel/DiffExcel.bat

Set .gitattributes

*.xls* diff=excel

Git Diff Usage

Totally the same as usual git diff, e.g.

git status

git diff theChangedExcelFile

and all other git diff

Other Output Examples

Changed Cells

New Worksheet

Missing Worksheet

尾声

DiffExcel为配合ExcelBDD而开发,是ExcelBDD开源项目的一部分,

参见ExcelBDD开源敏捷项目启动了!暨介绍微软Agile+DevOps免费平台-dev.azure.com

本文主体在dev.azure.com上维护,点击链接https://dev.azure.com/simplopen/ExcelBDD/_wiki/wikis/ExcelBDD.wiki/57/DiffExcel-Guideline可达。

以上是关于利用Git Diff比较Excel-推荐一款小工具的主要内容,如果未能解决你的问题,请参考以下文章

利用Git Diff比较Excel-推荐一款小工具

利用Git Diff比较Excel-推荐一款小工具

利用Rust与Flutter开发一款小工具

推荐一款专为新手用的Python开发工具

如何用一款小工具大大加速MySQL SQL语句优化

利用低代码从0到1开发一款小程序