[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Export data from Gridview to Excel

Posted on 2006-11-29
Medium Priority
Last Modified: 2008-02-01
Hi All,

I'm using asp.net 2.0 to develop a web site to export data from Gridview to Excel.
I can successfully export a excel for using the code below:

   Response.AddHeader("content-disposition", "attachment;filename=filename.xls")
   Response.Charset = ""
   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)

  Dim gv As GridView = GetGridView() '// a function to generate Gridview


This will export an excel with ONE (1) worksheet. Is it possible to Export an excel with TWO (2) or THREE (3) worksheet?
Is there other method to do it beside the about one?
Many thanks!

Question by:ywingyan
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2

Expert Comment

ID: 18036155
Just refer this link... a complete code...



Author Comment

ID: 18043295
thanks Mukesh,

But I can't find any different compare with mine. What I'm looking for is a method to export an Excel with more than one worksheet.

E.g. I have 2 GridView. gridView1 and gridView2. how to put the gridView1 on worksheet1 and gridView2 on worksheet2?

Independent Software Vendors: 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!


Author Comment

ID: 18099982
Thanks for vivekthangaswamy  provided another way to export the data without using gridview. but this link still can't fix my problem..

finally I design to paste all the reason in one WorkSheet instead of Three.

LVL 11

Accepted Solution

Vivek Thangaswamy earned 500 total points
ID: 18100104
LVL 11

Expert Comment

by:Vivek Thangaswamy
ID: 18264933
Hi ywingyan

Is my solution helped you???

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

649 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