public static void ExportToExcelFromTable(string fileName, HttpResponse response, HtmlTable Htable)
{
response.Clear();
response.AddHeader("content-disposition", "attachment;filename=" + fileName + ".xls");
response.Charset = "";
Htable.Border = 1;
Htable.BorderColor = "Black";
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);
Htable.RenderControl(htmlWrite);
response.Write(stringWrite.ToString());
response.End();
}
No comments:
Post a Comment