Solved

Export data from Gridview to Excel

Posted on 2006-11-29
8
308 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
Comment Utility
Just refer this link... a complete code...

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

Regards,
Mukesh
0
 

Author Comment

by:ywingyan
Comment Utility
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
Comment Utility
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:ywingyan
Comment Utility
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
Comment Utility
0
 
LVL 11

Expert Comment

by:Vivek Thangaswamy
Comment Utility
Hi ywingyan

Is my solution helped you???
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now