View differences in XLSX files stored in GIT
If you keep your XLSX files under version control in GIT you need a tool to effectively compare your revisions and resolve merge conflicts. xlCompare fills this gap and provides you with a solution. xlCompare can be configured as external diff tool for XLSX, XLSX, XLS, ODS and CSV files. With xlCompare you will effectively manage your development assets.
Integrate xlCompare into GIT step-by-step
Step 1 - Install xlCompare on your computer
Below we are using installation path to xlCompare application on your computer. By default xlCompare is installed into folder
C:/Users/{User Name}/AppData/Local/Spreadsheet Tools/xlCompare
But if you've installed it into other location, for example D:\xlCompare, you need to make appropriate changes.
Step 2 - Edit .git/config file
[diff "xlcompare"]
command = 'C:/Users/{User Name}/AppData/Local/Spreadsheet Tools/xlCompare/exceldiff.cmd'
[merge "xlcompare"]
name = xlCompare
driver = 'C:/Users/{User Name}/AppData/Local/Spreadsheet Tools/xlCompare/excelmerge.cmd' %A %O %B
[mergetool "xlcompare"]
cmd = 'C:/Users/{User Name}/AppData/Local/Spreadsheet Tools/xlCompare/excelmerge.cmd' \"$LOCAL\" \"$BASE\" \"$REMOTE\" \"$MERGED\"
trustExitCode = false
IMPORTANT:
- %A - LOCAL version of Excel file
- %O - BASE (common) version of Excel file
- %B - REMOTE version of Excel file
Why there are two lines for merge?
Step 3 - Connect Excel files in git with xlCompare
*.xlsx merge=xlcompare
Start using xlCompare with git diff command!
Integrate xlCompare into GUI tools like SourceTree, etc.?
Diff tool
Merge tool
IMPORTANT
NOTE
Questions and Answers
Why do we use CMD files as a drivers for diff and merge tools?
What is inside CMD file
- "%~dp0xlCompare.exe" - path to xlCompare application that is in the current directory
- %5 - LOCAL version of Excel file, git uses 7 arguments, 5-th one is a local file
- %2 - REMOTE version of Excel file
- quit_on_close - After you close the comparison xlCompare will exit. This will save you a second for clicking on the close button.
- titleMine:LOCAL - Git uses temporary file names, so LOCA and REMOTE will clearly identify the file.
- rep:"%__CD__%" - path to repository. This is highly important switch that should be used as last one. Without this parameter you will be unable to open files in subfolders.
- "%~dp0xlCompare.exe" - path to xlCompare application that is in the current directory
- git - says that it is used as external tool for GIT. It will exit after you close the comparison.
- merge - perform merge operation on the passed files and open GUI window is there are conflicts.
- titleMine:LOCAL - Git uses temporary file names, so LOCA and REMOTE will clearly identify the file.
- "%1" "%2" "%3" - paths to local, base and remote versions of Excel files.
- output:"%4" - if xlCompare is called with mergetool command, this switch tell xlCompare to save result file under $MERGED path. MERGED file is passed as 4-th argument in the mergetool syntax, described above.
- rep:"%__CD__%" - path to repository. This is highly important switch that should be used as last one. Without this parameter you will be unable to open files in subfolders.