Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

export aspx page to excel

Status
Not open for further replies.

whloo

Programmer
Apr 14, 2003
168
SG
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();
}
 
use OLE interfaces. Open the "Excel.Sheet" OLE object, add/remove workbooks and do anything whith them.

Ion Filipski
1c.bmp
 
thanks IonFilipski for your reply,

btw, i am quite new to this thing.
can u pls give me sample code for it.
thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top