Convert Excel format XLS to XLSX using C#

Jun 11, 2018 · 1 min read

I use EPPlus library to process Excel file (and automate a lot of work). It is a great library, very fast and full feature.

One disadvantage of EPPlus is lacking ability to work with old format XLS (which is binary format, belongs to Microsoft only)

We can convert XLS to XLSX using Excel Interop (you must have Excel installed on your computer).

  • Create new C# Console application
  • Run this in Package Management Console

Install-Package Microsoft.Office.Interop.Excel

Use this function

/// <summary>
/// Using Microsoft.Office.Interop to convert XLS to XLSX format, to work with EPPlus library
/// </summary>
/// <param name="filesFolder"></param>
public static string ConvertXLS_XLSX(FileInfo file) {
var app = new Microsoft.Office.Interop.Excel.Application();
var xlsFile = file.FullName;
var wb = app.Workbooks.Open(xlsFile);
var xlsxFile = xlsFile + "x";
wb.SaveAs(Filename: xlsxFile, FileFormat: Microsoft.Office.Interop.Excel.XlFileFormat.xlOpenXMLWorkbook);
return xlsxFile;

If this post helps you or saves your time, please go buy me a beer ;)