public static void ExportToExcel(string fileName, HttpResponse response, HtmlTableCell tc) {
response.Clear();
response.AddHeader("content-disposition", "attachment;filename=" + fileName + ".xls");
response.Charset = "";
response.Cache.SetCacheability(HttpCacheability.NoCache);
response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
//DataGrid dg = new DataGrid();
//dg.DataSource = dt;
//dg.DataBind();
tc.RenderControl(htmlWrite);
response.Write(stringWrite.ToString());
response.End();
}
No comments:
Post a Comment