taqi nazir

taqi nazir

  • NA
  • 25
  • 3.1k

Using Button and Grideview Export to Microsoft Excel Format

Jul 4 2013 10:48 AM
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)