The best and easiest way to convert csv file to excel file is here. This is the method I implemented and it is working fine.
Hope you all implement it.
private void Convert_CSV_To_Excel(string filename)
{
// Rename .csv To .xls
System.IO.File.Move( filename , filename .Replace(“.csv”, “.xls”));
var _app = new MX.Application();
var _workbooks = _app.Workbooks;
_workbooks.OpenText( filename .Replace(“.csv”, “.xls”),
DataType: MX.XlTextParsingType.xlDelimited,
TextQualifier: MX.XlTextQualifier.xlTextQualifierDoubleQuote,
ConsecutiveDelimiter: true,
Comma: true);
_app.AlertBeforeOverwriting = false;
_workbooks[1].Save();
_workbooks.Close();
}
Happy Coding Friends 😀 . If you have any easy way to convert it please reply me.
Defining Connection string in Notepad file and common method to connect to multiple databases
How to Open dynamically specific extension file from a directory