troubleshooting Question

Export to excel with paging

Avatar of gogetsome
gogetsomeFlag for United States of America asked on
2 Comments1 Solution378 ViewsLast Modified:
Hello, I'm trying to export a girdview to excel with paging turned on. I have used the code below to export other gridviews but none with paging set. How can I modify the code to export the whole dataset to excel rather than the first set of rows dispayed in the paged gridview?

Here is my code:

 Sub exportToExcel()

        Response.AddHeader("content-disposition", "attachment;filename=FileName.xls")
        Response.Charset = ""
        ' If you want the option to open the Excel file without saving than
        ' comment out the line below
        ' Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.ContentType = "application/vnd.xls"
        Dim stringWrite As System.IO.StringWriter = New System.IO.StringWriter()
        Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)

    End Sub
    Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
        ' Confirms that an HtmlForm control is rendered for the specified ASP.NET server control at run time.
    End Sub
    'exports the gridview to excel
    Protected Sub btnExport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExport.Click
    End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros