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 ;)


Written by


Developer, Sportman. Write code with joy, bake app with heart. Opinions are my own. If you feel I save your time, go

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade