• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

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
0
inewman
Asked:
inewman
1 Solution
 
thefritterfatboyCommented:
Personally, I'd use SpreadSheetML - Not HTML to create Excel documents.

It takes some getting used to but it's much more accurate:

http://ewbi.blogs.com/develops/2005/01/create_excels_s.html
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now