Save an excel file to a csv file in C# code

前端 未结 3 1830
遇见更好的自我
遇见更好的自我 2020-12-06 18:09

I want to open an excel file and save it as a csv file. Google search no lucky. I need C sharp code to do it.

Thanks for your nice help.

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-06 18:23

    If you are willing to use Excel Interop:

            Excel.Application app = new Excel.Application();
            Excel.Workbook wb = app.Workbooks.Open(@"c:\temp\testtable.xlsx");
            wb.SaveAs(@"C:\Temp\output.csv", Excel.XlFileFormat.xlCSVWindows);
            wb.Close(false);
            app.Quit();
            Console.WriteLine("Done!");
    

提交回复
热议问题