A script to render an excel (.xlsx) workbook as text suitable to use with
diff and, in particular, git diff, to get readable diffs, for example with
Git. Inspired by William Usher's git_diff_xlsx
which he wrote for working with the UK TIMES model (see his blog).
I wrote this in Ruby (using rubyXL) because thats the language of the other UK-TIMES tools
Options to:
- hide formulas, and show only values (useful for regression testing)
- hide calculated values for formulas and show just the formulas (useful for git diffs)
On Linux, I create a link called xl-textconv in my ~/bin.
Usage: xl-textconv [options] <workbook-file>
-v, --no-values Exclude calculated values
-f, --no-formulas Exclude cell formulas
-h, --help Show this message
See the Git Book
Tell git that files ending xlsx are to be treated as Excel for diff:
create .gitattributes file in the root of your repo with the following:
*.xlsx diff=excel
Tell Git how to diff Excel files: in .git/config:
[diff "excel"]
binary = True
textconv = xl-textconv -v
cachetextconv = true
See also This node.js version with some interesting notes on use, including using cachetextconv
- I'm not a Ruby programmer.
- There are no tests.