Wednesday, May 9, 2012

Export To HTML

public void ExportToHTML(DataTable pdtblData)
{
string strFileData = string.Empty;
byte[] bytFileData = null;
string strfname = string.Empty;
strFileData = GetHTMLData( pdtblData);
bytFileData = Encoding.ASCII.GetBytes(strFileData.ToString());
strfname = Services.IDGenerator.GetUniqueKeyWithPrefix(_strPerfix, 10) + ".html";
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + strfname);
System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
System.Web.HttpContext.Current.Response.BinaryWrite(bytFileData);
System.Web.HttpContext.Current.Response.End();

}

No comments: