Excel file regression test with C#

In my current assignment / project we are running regression tests of text, csv and excelfiles. The system is based on .NET / C# and daily builds. Every night the checked in developed code is built and the system is built up from scratch. A number of output files should be the same as the day before i.e. regression test.

For C# there are a lot of ready solutions for comparing (diffs) excel files but we had no such at hands. We needed to built this on our own.

First I needed to convert excel files to csv files in order to make an easy compare/diff. For this I’m using a Visual Basic script that has been published on many sites.


To use it just ”Please specify the source and the destination files. Usage: ExcelToCsv <xls/xlsx source file> <csv destination file>”. You can call it from C# in the same way as you diff files (see below).

In order to diff files I use the FC tool in windows and call this from C# with Process.start. Here is a sample code:

So this is a simple way to regression test excel files in C# with simple scripts.