Click here to Skip to main content
15,890,609 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi.i want to grid view to excel
but Empty save to excel or null

iam this code
C#
GVAS.Visible = false;
       Response.Clear();
       Response.Buffer = true;
      // Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.doc");

     //  Response.ContentType = "application/vnd.ms-word ";
       Response.ContentType = "application/vnd.xls";
       Response.Charset = "";
       Response.AddHeader("content-disposition",
               "attachment;filename=MyList.xls");
       StringWriter sw = new StringWriter();
       HtmlTextWriter hw = new HtmlTextWriter(sw);
       GVAS.AllowPaging = false;
       GVAS.DataBind();
       GVAS.RenderControl(hw);
       Response.Output.Write(sw.ToString());
       Response.Flush();
       Response.End();
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900