Solved

Export data from Gridview to Excel

Posted on 2006-11-29
8
310 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

770 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