Solved

exporting html table to excel is exporting whole page?

Posted on 2011-03-04
1
701 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 500 total points
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now