string fname = drop.SelectedValue + ".xls";
string namee = fname;
System.IO.FileInfo finfo = new System.IO.FileInfo(fname);
Response.Clear();
Response.AppendHeader("content-type", "application/x-msexcel");
Response.AppendHeader("content-disposition", "attachment; filename=" + drop.SelectedItem.Text + ".xls");
Response.End();
// I have created empty Excel Sheet but the problem is while opening its show me error like the file u r trying to open filename.xls is in a different format than specified by the file extension verify that the file is not corrupted and it from a trusted source before opening the file
Pranay KantPosted Sep 15, 2015, 4:26 AM
You could refer to the article from codeproject Using C# to create an Excel or you could simple use some third party library like free Spire.XLS to create Excel with simple code.
akshay rasalakarPosted Sep 10, 2015, 9:05 AM
Bobby MilliganPosted Sep 10, 2015, 3:05 AM
akshay rasalakarPosted Sep 9, 2015, 11:01 AM
Khan Abrar AhmedPosted Sep 1, 2015, 8:10 AM
string namee = fname;
System.IO.FileInfo finfo = new System.IO.FileInfo(fname);
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + drop.SelectedItem.Text + ".xls");
Response.ContentType = "application/x-msexcel";
Response.End();
if contenet type will not work then try the below content type
Response.ContentType = "application/vnd.ms-excel";
Rojalin SahooPosted Sep 1, 2015, 3:42 AM