In this post Find GridView Data in Excel Format
using System.IO; ------------------ Convert to Excel Button ( Click Event ) Coding ----------------------------------------------- Response.ClearContent(); Response.Buffer = true; Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "ProductDetail.xls")); Response.ContentType = "application/ms-excel"; StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); GridView1.AllowPaging = false; GridView1.HeaderRow.Style.Add("background-color", "#FFFFFF"); for (int i = 0; i < GridView1.HeaderRow.Cells.Count; i++) { GridView1.HeaderRow.Cells[i].Style.Add("background-color", "#507CD1"); } int j = 1; foreach (GridViewRow gvrow in GridView1.Rows) { gvrow.BackColor = System.Drawing.Color.White; if (j <= GridView1.Rows.Count) { if (j % 2 != 0) { for (int k = 0; k < gvrow.Cells.Count; k++) { gvrow.Cells[k].Style.Add("background-color", "#EFF3FB"); } } } j++; } GridView1.RenderControl(htw); Response.Write(sw.ToString()); Response.End(); ---------------------------------------------------- public override void VerifyRenderingInServerForm(Control control) { /* Verifies that the control is rendered */ }