Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 158741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:44:06+00:00 2026-05-11T10:44:06+00:00

I would like to export a GridView to excel, which is easy enough. But

  • 0

I would like to export a GridView to excel, which is easy enough. But above the grid, in Excel, I would like some other information for identification. Can I somehow export things other than gridviews while then putting in the gridview below?

Edit: For some reason when the GridView1 is visible and I try to export, the entire page exports and not just the gridview. Not sure why!

Protected Sub btnExport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExport.Click     'Create a StringWriter and HtmlTextWriter     Dim sw As System.IO.StringWriter = New System.IO.StringWriter()     Dim htw As New System.Web.UI.HtmlTextWriter(sw)      'Clear the Response object's content and specify the header for the HTML response and type of application file to create     Response.ClearContent()     Response.AddHeader('content-disposition', 'attachment; filename=SaveFile.xls')     Response.ContentType = 'application/vnd.ms-excel'     Response.Charset = ''     EnableViewState = False      htw.WriteLine('Test, test, test')      Try         'Check for the number of GridView rows         If GridView1.Rows.Count < 65535 Then             'Turn sorting and paging off and rebind the GridView control             GridView1.AllowSorting = False             GridView1.AllowPaging = False             GridView1.PageSize = GridView1.Rows.Count             GridView1.AutoGenerateSelectButton() = False             GridView1.DataBind()               'Render the GridView1 as HTML - this will cause an error that will fire the VerifyRenderingInServerForm event -- this event is trapped by the Overriding sub procedure given at the end of the program listing             GridView1.RenderControl(htw)              'Write the response             Response.Write(sw.ToString())             Response.End()              'Turn sorting and paging on and rebind the GridView control             GridView1.AllowSorting = True             GridView1.AllowPaging = True             '.GridView1.PageSize = 10             GridView1.AutoGenerateSelectButton() = True             GridView1.DataBind()         End If     Catch ex As Exception      End Try  End Sub 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T10:44:07+00:00Added an answer on May 11, 2026 at 10:44 am

    Yes you can.

    Do something like this:

    HttpContext.Current.Response.Write('some string value') 

    before you pass your gridview.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Excel table with some data that I would like to export
I have a simple table which I would like to export to an Excel
--I have some rows from my table which I would like to export in
I would like to export some macros that I have defined and be able
Im writing app in haskell and I would like to export some functions and
I would like to export an HTML table to a MS Excel document (and
I would like to export (or to keep) the subtags which are with the
I would like to be able to export my WF diagram from visual studio
I have a project where I would like to generate a report export in
From our existing, internal tracking system I would like to create an XML export

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.