For those who want to use Interop instead of an external library, you can simply do this:
Application app = new Application();
Workbook wb = app.Workbooks.Open(@"C:estcsv.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);
wb.SaveAs(@"C:estcsv.xlsx", XlFileFormat.xlOpenXMLWorkbook, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
wb.Close();
app.Quit();
The second argument of Workbook.SaveAs determines the true format of the file. You should make the filename extension match that format so Excel doesn't complain about corruption. You can see a list of the types and what they mean on MSDN.
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.xlfileformat.aspx
As always, please keep Microsoft's considerations in mind if this functionality is intended for a server environment. Interop may not be the way to go in that situation:
http://support.microsoft.com/kb/257757
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…