public static void ExportToExcelFromWebTable(string fileName, HttpResponse response, Table Wtable)
{
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);
System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
DataSet ds = new DataSet("Wtable");
// ds = ((System.Data.DataSet)Wtable).Copy();
DataGrid dg = new DataGrid();
dg.DataSource = ds;
dg.DataBind();
dg.RenderControl(htmlWrite);
response.Write(stringWrite.ToString());
//response.Write(Wtable.ToString());
dg.RenderControl(htmlWrite);
response.Write(stringWrite.ToString());
//response.Write(Wtable.ToString());
response.End();
}
No comments:
Post a Comment