Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > Other ASP.NET > ASP.NET 1.x and 2.0 Application Design
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 24th, 2005, 02:45 AM
Authorized User
 
Join Date: May 2005
Location: Kolkata, W.B., India.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to Export data, of a DataSet to an Excel File

Hi Friends,

How are you all? Hope you all are doing well. I am doing an ASP.NET project with C#. I have to export the data of a DataSet to an EXCEL file.

Please give me the code example of C# on that.

Thanks,

Regards,

Swadhin.
  #2 (permalink)  
Old May 24th, 2005, 06:57 AM
Friend of Wrox
 
Join Date: Jun 2004
Location: Chennai, Tamil Nadu, India.
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default

You can load a datagrid with the dataset and then call the RenderControl method to export it to Excel. I am not sure how to export directly from a dataset. I normally do this way

Regards
Ganesh
  #3 (permalink)  
Old May 24th, 2005, 08:02 AM
Authorized User
 
Join Date: May 2005
Location: Kolkata, W.B., India.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Ganesh,

You have said that I can call ReaderControl method to export data to excel in ASP.NET project with C#. Can you give me code example on that?

Thanks,

Regards,

Swadhin.
  #4 (permalink)  
Old May 24th, 2005, 11:00 PM
Friend of Wrox
 
Join Date: Jun 2004
Location: Chennai, Tamil Nadu, India.
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default

1st you have to bind the grid with data
Code:
Response.Clear(); 
Response.Buffer = true; 
Response.ContentType = "application/vnd.ms-excel"; 
Response.Charset = ""; 
EnableViewState = false; 
System.IO.StringWriter oStringWriter = new System.IO.StringWriter(); 
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter); 

grdSrcRequestExport.RenderControl(oHtmlTextWriter); 

Response.Write(oStringWriter.ToString()); 
Response.End();
Regards
Ganesh
  #5 (permalink)  
Old May 24th, 2005, 11:55 PM
Authorized User
 
Join Date: May 2005
Location: Kolkata, W.B., India.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Ganesh,

Thanks, Thanks a lot.

Regards,

Swadhin.
  #6 (permalink)  
Old May 25th, 2005, 11:11 PM
Friend of Wrox
 
Join Date: Jun 2004
Location: Chennai, Tamil Nadu, India.
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default

Cheers Swadhin

Sometimes you may need to assign the values in the template columns to the column so that all columns are exported correctly

Regards
Ganesh
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataSet export to .csv file snufse1 ASP.NET 2.0 Basics 3 September 22nd, 2008 07:22 AM
Can we directly export dataset to EXCEL deb_kareng ASP.NET 2.0 Professional 1 August 6th, 2007 07:49 AM
Export dataset to Excel zaghmout ASP.NET 2.0 Professional 1 June 21st, 2007 04:10 AM
Export GridView data to Excel file rao965 ASP.NET 2.0 Professional 0 June 14th, 2007 10:18 AM
export dataset into existng ms access data drachx General .NET 0 October 13th, 2005 08:50 PM



All times are GMT -4. The time now is 04:09 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.