Solved

Export data from Gridview to Excel

Posted on 2006-11-29
8
317 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
[X]
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
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
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

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…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

719 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