Hi,
I want to export gridview data to exel but after exporting i want to see a heading of the co and address above the data in excel and even image of the company...for that purpose which code should i suppose to use.
Please help me,
I want to export data from gridview to excel
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Raj KumarRank #25 · 44.2K reputationPosted May 19, 2013, 8:05 PM EDT
This is button click code...myDataGrid is datagrid name
protected void btnExcel_Click1(object sender, EventArgs e)
{
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
myDataGrid.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
}