Reputation: 702
I'm looking for a way to essentially take a folder of excel files that are the old 2003 file extension .xls and convert them into .xlsm. I realize you can go into the excel sheet yourself and manually do it, but is there anyway to do it with code? Specifically using any sort of library?
Upvotes: 11
Views: 26100
Reputation: 3289
This is not my code, but I have used ClosedXML before and it is awesome. I found this on the FAQ asking if it supports Excel 2003 which looks like it should work for you...
To clarify, this uses the Office Interop library not closedXML, but I mentioned it incase you had any additional modifications you needed.
public void Convert(String filesFolder)
{
files = Directory.GetFiles(filesFolder);
var app = new Microsoft.Office.Interop.Excel.Application();
var wb = app.Workbooks.Open(file);
wb.SaveAs(Filename: file + "x", FileFormat: Microsoft.Office.Interop.Excel.XlFileFormat.xlOpenXMLWorkbook);
wb.Close();
app.Quit();
}
hope it helps :D
Upvotes: 21