1
Answer

Using Button and Grideview Export to Microsoft Excel Format

taqi nazir

taqi nazir

11y
966
1
Export to Microsoft Excel Format
please explain this code

 protected void Buttonexp_Click(object sender, EventArgs e)
        {
            Response.Clear();
            Response.AddHeader("content-disposition", "attachment;filename=GridView_to_Excel.xls");
            Response.Charset = "";
            Response.ContentType = "application/vnd.xls";
            StringWriter StringWriter = new System.IO.StringWriter();
            HtmlTextWriter HtmlTextWriter = new HtmlTextWriter(StringWriter);
            GridView1.RenderControl(HtmlTextWriter);
            Response.Write(StringWriter.ToString());
            Response.End();
    }

        public override void VerifyRenderingInServerForm(Control control)
        {

        }
Answers (1)