Solved

Export data from Gridview to Excel

Posted on 2006-11-29
8
312 Views
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.Clear()
   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

  gv.RenderControl(htmlWrite)
  Response.Write(stringWrite.ToString)
  Response.End()


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!

Ashley
0
Comment
Question by:ywingyan
  • 3
  • 2
8 Comments
 
LVL 5

Expert Comment

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

http://geekswithblogs.net/azamsharp/archive/2005/12/21/63843.aspx

Regards,
Mukesh
0
 

Author Comment

by:ywingyan
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?

Regards,
Ashley
0
 
LVL 11

Expert Comment

by:Vivek Thangaswamy
ID: 18094312
0
Industry Leaders: 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

by:ywingyan
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.

THanks
0
 
LVL 11

Accepted Solution

by:
Vivek Thangaswamy earned 125 total points
ID: 18100104
0
 
LVL 11

Expert Comment

by:Vivek Thangaswamy
ID: 18264933
Hi ywingyan

Is my solution helped you???
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
No Data for DropDown List 2 32
reading excel file in .net 2 30
Asp.net 4 FileUpload gets "Permission Denied" when Uploading file 8 33
Calculating percentage 2 26
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…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

680 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