Link to home
Start Free TrialLog in
Avatar of inewman
inewman

asked on

Output ASP tables to Excel and creat seperate worksheets

I have an ASP web page that creates 3 tables from a SQL data base.  I am abel to export the tables to Excel using the following code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Response.Clear()
        Response.Buffer = True
        Response.ContentType = "application/vnd.ms-excel"

        Response.Charset = ""

        Dim oStringWriter As System.IO.StringWriter = New System.IO.StringWriter
        Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New System.Web.UI.HtmlTextWriter(oStringWriter)

        tb2.RenderControl(oHtmlTextWriter)
        lbl1.RenderControl(oHtmlTextWriter)
        tb3.RenderControl(oHtmlTextWriter)
        lbl2.RenderControl(oHtmlTextWriter)
        tb4.RenderControl(oHtmlTextWriter)
        lbl3.RenderControl(oHtmlTextWriter)
        tb5.RenderControl(oHtmlTextWriter)
        Response.Write(oStringWriter.ToString())

        Response.End()

    End Sub


Each table is seperated by a label and all three tables are on one worksheet.

I would like to creat a seperate worksheet in the Excel workbook for each table. How can this be done?

Thanks.

Ira
ASKER CERTIFIED SOLUTION
Avatar of thefritterfatboy
thefritterfatboy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial