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
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
Reply
 
Thread Tools 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

Twyce!
__________________
Twyce!
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
Default

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

Rob
http://cantgrokwontgrok.blogspot.com
Reply With Quote
  #3 (permalink)  
Old September 9th, 2008, 03:25 PM
samjudson's Avatar
Friend of Wrox
Points: 8,352, Level: 39
Points: 8,352, Level: 39 Points: 8,352, Level: 39 Points: 8,352, Level: 39
Activity: 35%
Activity: 35% Activity: 35% Activity: 35%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,072
Thanks: 1
Thanked 178 Times in 177 Posts
Default

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, 03:51 AM
Registered User
 
Join Date: Mar 2010
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

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:

Code:
var people = (DataTable)dataGrid.DataSource;

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

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

Response.Clear();
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();
ef.SaveXlsx(ms);
ms.WriteTo(Response.OutputStream);

Response.End();
Reply With Quote
Reply


Thread Tools
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 10:57 AM
Exporting DataGrid To Excel chiefg C# 2 December 31st, 2003 11:23 AM



All times are GMT -4. The time now is 10:01 PM.


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