Asp.net Export to Excel from GridView in 2007

  • Thread starter Thread starter Krishna KV
  • Start date Start date
K

Krishna KV

Guest
Hi,

Iam getting when export to excel in asp.net

The file you are trying to open is in a different format than specified by the file extension


This my code

Response.ClearContent();

Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=Test.xls");


GridView excel = new GridView();
excel.DataSource = dt;
excel.DataBind();
excel.RenderControl(new HtmlTextWriter(Response.Output));


Response.Flush();
Response.End();


Thanks

Krishna

Continue reading...
 
Back
Top