Programmatically convert Excel 2003 files to 2007+

前端 未结 1 1493
我在风中等你
我在风中等你 2020-12-25 08:50

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 exce

相关标签:
1条回答
  • 2020-12-25 09:17

    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

    0 讨论(0)
提交回复
热议问题