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?
If you are using Office 2007, and have a 2003 file open (in Compatibility Mode), you can Convert the file to 2007. Just click on the Office button in the top left corner and select Convert from the menu. It will be converted to a 2007 file format, and will stay in the 2007 format when you change it.
Follow these steps: Click File > Export > Change File Type. Under Workbook File Types, double-click Excel 97-2003 Workbook (*. xls).
From the 2003 computer where it is, stick the file onto a flash drive, bring it over to the 2010 computer, and put it into whatever folder you want. Then, open the file, click the green File tab, and save as for file type Excel macro enabled workbook.
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();
}
Here is the link
hope it helps :D
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With