Save versions of Excel file on Git to reconcile di

2019-07-23 13:14发布

I will be one month updating Excel files. These files are in a language other than English. I thought I could use Git too to manage what I want to do.

The situation (the initial commit)

I have an Excel file that is written in the other language.

I have to perform some work and fill an Excel file with data from that.

My plan

After an initial commit, create a branch called toEnglish. Then translate some text on the Excel files to English so that I feel more comfortable. Once I do this I will commit.

Then, the one-month work will start and I will fill the data in the Excel file. I will commit periodically.

After the one month finishes, I will commit, and so I will have the data filled in a Excel page where some labels are in English.

However the output of that one month work has to have those labels in the original language.

So I have a original branch with the original language labels but no data and the toEnglish branch with the data but English labels.

The question

I can not merge (fast-forward merge) the branches since that will eliminate the original language labels, so how can I merge in order to produce conflicts (the labels in two different languages) that I will solve one by one so that the final merge will have both the data and the labels in the original language?

标签: excel git
3条回答
仙女界的扛把子
2楼-- · 2019-07-23 13:50

Excel is a bit useless in Git - it does not matter whether it is a binary (xlsb or not xlsx) - it will just copy the file and leave it as it is. Thus, it is a bit of a challenge to do a working source control for VBA developers - in general it is accepted that it does not exist and cannot be done (this is what I usually hear), but there are some ways for workaround - e.g., if you follow MVC and you do not put any business logic in the worksheets.

What you can do is simply to save the worksheets to a csv and proceed working as if it is normal plain text. At the end, even some "manual" merge with formulas is possible, based on the different worksheets (this is the bonus excel gives).

查看更多
干净又极端
3楼-- · 2019-07-23 13:56

There is an open-source Git extension that makes Excel workbook files diff- and mergeable: https://github.com/ZoomerAnalytics/git-xltrail (disclaimer, I'm one of the authors)

It installs a custom differ and merger for xls* types and configures Git accordingly so that it behaves the same way as if it were a text file.

For docs and a short video, have a look at https://www.xltrail.com/client

查看更多
啃猪蹄的小仙女
4楼-- · 2019-07-23 14:14

There is an even bigger problem with versioning Excel files in Git, which is that Excel files (xls and xlsx) are binary. Git doesn't generally handle binary very well. Each commit you make on an Excel file will likely record the entire file as the diff. In addition, comparing Excel files from two different commits/branches won't give you much insight.

One workaround which comes to mind would be to version plain text CSV versions of your Excel worksheets. Such CSV files would likely version well with Git. Of course, if the worksheets have lots of rich content on top of the data, then this option might not work as well.

查看更多
登录 后发表回答