Hi,
I am trying to export my aspx page to excel.
i manage to do it using the code below.
but what i want to achieve is to save the whole page into an excel file instead of just display it on the page.
How can i achieve that?
Thanks!
private void ExportToExcelButImg_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
string strhtml = "";
Response.ContentType = "application/vnd.ms-excel";
Response.AppendHeader("Content-Disposition", "filename=Reporte.xls;"
Response.Charset = "";
Response.Buffer = false;
this.EnableViewState = false;
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new Html32TextWriter(tw);
Page.RenderControl(hw);
strhtml = tw.ToString();
Response.Write(strhtml);
Response.Flush();
Response.End();
}
I am trying to export my aspx page to excel.
i manage to do it using the code below.
but what i want to achieve is to save the whole page into an excel file instead of just display it on the page.
How can i achieve that?
Thanks!
private void ExportToExcelButImg_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
string strhtml = "";
Response.ContentType = "application/vnd.ms-excel";
Response.AppendHeader("Content-Disposition", "filename=Reporte.xls;"
Response.Charset = "";
Response.Buffer = false;
this.EnableViewState = false;
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new Html32TextWriter(tw);
Page.RenderControl(hw);
strhtml = tw.ToString();
Response.Write(strhtml);
Response.Flush();
Response.End();
}