Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 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 September 9th, 2008, 03:12 PM
Registered User
Join Date: Sep 2008
Location: Port Elizabeth, Eastern cape, South Africa.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to twyce
Default Exporting data from datagrid to excel???

I'm exporting data from a datagrid to an excel spreadsheet.I want the spreadsheet to open and display the data when the data is exported(when you click button export).How do i go about making that happen.Please help

Reply With Quote
  #2 (permalink)  
Old September 9th, 2008, 03:20 PM
Friend of Wrox
Join Date: Mar 2007
Location: Hampshire, United Kingdom.
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post

Try looking up the Office PIA's they pretty much do everything you can do in Office to Office from .NET :D

Reply With Quote
  #3 (permalink)  
Old September 9th, 2008, 03:25 PM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts

This is by far and above THE most asked question on this forum, and shows a distinct lack of research on the part of anyone who asks it.

/- Sam Judson : Wrox Technical Editor -/
Reply With Quote
  #4 (permalink)  
Old March 4th, 2010, 04:51 AM
Registered User
Join Date: Mar 2010
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts


for exporting DataGrid to Excel in Excel ASP.NET application, I recommend you take a look at this Excel C# component.

It doesn't require Excel Automation and API is pretty simple and intuitive:

var people = (DataTable)dataGrid.DataSource;

// Create excel file.
var ef = new ExcelFile();
var ws = ef.Worksheets.Add("DataSheet");

ws.InsertDataTable(people, "A1", true);

Response.ContentType = "application/vnd.openxmlformats";
Response.AddHeader("Content-Disposition", "attachment; filename="
+ "Report.xlsx");

// With XLSX it is a bit more complicated as MS Packaging API
// can't write directly to Response.OutputStream.
// Therefore we use temporary MemoryStream.
var ms = new MemoryStream();

Reply With Quote

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
Problem in exporting data from datagrid to Excel deb_kareng ASP.NET 2.0 Professional 4 August 4th, 2007 09:21 AM
exporting to excel from datagrid hotshot_21 ASP.NET 1.0 and 1.1 Basics 2 June 9th, 2006 08:53 AM
Exporting data to excel from datagrid, Problem. swadhinm ASP.NET 1.x and 2.0 Application Design 0 May 31st, 2005 01:44 AM
problem exporting datagrid to excel kscdave Classic ASP Professional 0 March 29th, 2005 11:57 AM
Exporting DataGrid To Excel chiefg C# 2 December 31st, 2003 12:23 PM

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

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