?
Solved

exporting html table to excel is exporting whole page?

Posted on 2011-03-04
1
Medium Priority
?
716 Views
Last Modified: 2012-05-11
I have a html table on my page:
<table runat="Server" id="TESTTABLE">
            <tr>
                <td style="padding:0 30px 0 0;">
..................... etc etc

In my code behind then on a button click I have:
Dim filename As String = "urXlfileName.xls"
        Response.Clear()
        Response.Buffer = True
        Response.ContentType = "application/vnd.ms-excel"
        Response.AddHeader("Content-Disposition", "attachment; filename=""" & filename & """")
        Response.ContentEncoding = System.Text.Encoding.UTF7
        Response.Charset = ""
        EnableViewState = False
        Dim strWriter As New StringWriter
        Dim htmlWriter As New System.Web.UI.HtmlTextWriter(strWriter)
        CType(TESTTABLE, HtmlTable).RenderControl(htmlWriter)
        Response.Write(strWriter)

I am getting an export to excel but it is exporting the whole page rather than just the html table.

Why is this?

Thanks
0
Comment
Question by:scm0sml
1 Comment
 
LVL 7

Accepted Solution

by:
vbwizardry earned 2000 total points
ID: 35037152
add Response.End after Response.Write(strWriter)
Response.Write(strWriter)
Response.Flush()
Response.End()

Open in new window


See if this will help.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month17 days, 5 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question