Export GridView Data into Excel in C# .Net
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition",
"attachment;filename=GridViewExport.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
GridView1.RenderControl(hw);//DataGrid Name
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
Response.Buffer = true;
Response.AddHeader("content-disposition",
"attachment;filename=GridViewExport.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
GridView1.RenderControl(hw);//DataGrid Name
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
thus code help to me ..
ReplyDeleteso thanx dear ...