When I download excel using this code I am getting the warning.
"The file type you are trying to open is in a different format...."
How to avoid this?
public FileResult ExportExcel()
{
DataTable dt = new DataTable();
DataRow dr = dt.NewRow();
dt.Columns.Add("name");
dr["name"] = "test";
dt.Rows.Add(dr);
DataSet ds = new DataSet();
ds.Tables.Add(dt);
string csv_text = ToCSV(dt);
byte[] toBytes = Encoding.ASCII.GetBytes(csv_text);
return File(toBytes, "application/ms-excel", "mytestfile.xls");
}