Convert CSV file to excel XLS file

  • Thread starter Thread starter CSharp Enthusiast
  • Start date Start date
C

CSharp Enthusiast

Guest
I am working on saving a .csv file as an excel .xls file using the below code. This uses assembly reference to the Microsoft.Office.Interop.Excel.dll. I am looking to explore different ways to approach this problem. Please let me know what other options are available.

Application xlap = new Application();
Workbook xlwb = xlap.Workbooks.Open(@"C:\temp\test.csv", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
xlwb.SaveAs(@"C:\temp\test.xls", XlFileFormat.xlOpenXMLWorkbook, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
xlwb.Close();
xlap.Quit();

Thank you in advance.


SQLEnthusiast

Continue reading...
 
Back
Top