Posted on: 5/7/2012 4:22:26 PM | Views : 263

hi,
i'm new to asp.net, i'm creating a website in that i'm retrieving data from sql & bound to gridview ,i'm trying to export gridview to excel (using click button ) ...its not working properly....in excel file its showing like <div>....</div>
Code which i'm using is....
protected void Button1_Click(object sender, EventArgs e) { Response.Clear(); Response.Buffer = true; Response.AddHeader("content-disposition","attachment;filename=ActualsAndBudgets.xls"); Response.Charset = ""; Response.ContentType = "application/ms-excel"; Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); gridviewPharmaResult.AllowPaging = false; gridviewPharmaResult.DataBind(); gridviewPharmaResult.RenderControl(htw); Response.Write(sw.ToString ()); ...

Go to the complete details ...