01.
using
System.IO;
02.
03.
Response.ClearContent();
04.
Response.AddHeader(
"content-disposition"
,
"attachment;filename=Excel_Name.xls"
);
05.
Response.Cache.SetCacheability(HttpCacheability.NoCache);
06.
Response.ContentType =
"application/ms-excel"
;
07.
StringWriter sw =
new
StringWriter();
08.
HtmlTextWriter htw =
new
HtmlTextWriter(sw);
09.
HtmlForm frm =
new
HtmlForm();
10.
frm.Attributes[
"runat"
] =
"server"
;
11.
frm.Controls.Add(GridViewName);
12.
qwGVExcel.RenderControl(htw);
13.
Response.Write(sw.ToString());
14.
Response.End();