How to convert an XLS Excel file to XLSX Excel file
Introduction
This C# recipe shows how you can convert a XLS file to XLSX file.
Ingredients
The recipe uses the Microsoft.Office.Interop.Excel Nuget package. You can install it using Nuget Package manager:
Install-Package Microsoft.Office.Interop.Excel
Warning! This solution will only work on a server where Excel is installed. So if you are deploying your solution to the cloud - such as Azure - this solution is unlikely to work.
C# Code Snippet
var files = Directory.GetFiles(filesFolder);
var interOpApp = new Microsoft.Office.Interop.Excel.Application();
var workBook = interOpApp.Workbooks.Open(file);
workBook.SaveAs(Filename: file + "x", FileFormat: Microsoft.Office.Interop.Excel.XlFileFormat.xlOpenXMLWorkbook);
workBook.Close();
interOpApp.Quit();