473,467 Members | 1,303 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Exporting datagrid to Excel in a Windows Application

Hi all,

I am trying to export the content of a datagrid to Excel format (xls) in
a Windows Application,

I google a bit, but the examples I found were focus on ASP.net, using
the response object, e.g.

HttpResponse response = HttpContext.Current.Response;
response.ContentType = "application/vnd.ms-excel";
How to achieve the same in a C# windows application?

Thanks a lot!
KC Eric
Jun 18 '06 #1
2 4364
Eric,

It would be very different. Your best bet is to either use the OLEDB
adapter for Excel/CSV files, or to populate a sheet using Excel automation.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"KC Eric" <kc@nospam.com> wrote in message
news:eb**************@TK2MSFTNGP05.phx.gbl...
Hi all,

I am trying to export the content of a datagrid to Excel format (xls) in
a Windows Application,

I google a bit, but the examples I found were focus on ASP.net, using
the response object, e.g.

HttpResponse response = HttpContext.Current.Response;
response.ContentType = "application/vnd.ms-excel";
How to achieve the same in a C# windows application?

Thanks a lot!
KC Eric

Jun 18 '06 #2
There is .net component call spire.dataexport, I have heard that it is
quite good for generating Excel files. It can create Excel files
without MS Excel installed on the machine,Free download.
http://www.e-iceblue.com
KC Eric 写道:
Hi all,

I am trying to export the content of a datagrid to Excel format (xls) in
a Windows Application,

I google a bit, but the examples I found were focus on ASP.net, using
the response object, e.g.

HttpResponse response = HttpContext.Current.Response;
response.ContentType = "application/vnd.ms-excel";
How to achieve the same in a C# windows application?

Thanks a lot!
KC Eric
Jul 18 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Michael | last post by:
I need to be able to export data from a web form into MS Excel. I know you can do it with a VB.net windows application, but how can you do it with an asp.net application using vb.net? Any help...
1
by: ad | last post by:
I use the code below to export the content of a data set to Excel, the code come form http://www.dotnetjohn.com/articles.aspx?articleid=36 But it always use the web form's name as the default...
4
by: Hitesh | last post by:
Hi, I have three datagrid control on my aspx page and one export to excel button, i want to export all the 3 datagrids contents in one excel file. how can i achive that? -- Thanks Hitesh
1
by: NancyA | last post by:
I am using the following code to write data from a datagrid to an Excel file: Dim tw As New System.IO.StringWriter Dim hw As New System.Web.UI.HtmlTextWriter(tw) dg.RenderControl(hw)...
3
by: | last post by:
Hello, I have a routine in my Windows application that exports the contents of a datagrid to Excel. It is modeled closely after the HowTo example on MSDN: http://tinyurl.com/5g2jm. Depending...
2
by: bienwell | last post by:
Hi, I have a question about exporting data from datagrid control into Excel file in ASP.NET. On my Web page, I have a linkbutton "Export data". This link will call a Sub Function to perform...
6
by: Coleen | last post by:
Hi All :-) I'm using .Net Framework 1.1, VB and need to be able to download the data from a datagrid into an Excel 2000 spreadsheet for our accounting users. Can anyone please point me to a good...
6
by: Opa | last post by:
Hi, I have a DataGrid, whose sourceI am exporting to Excel. This works fine except for the Column ordering. My datasource is not a datatable, with a typical SELECT statement where I can...
0
by: kanepart2 | last post by:
Hi , I have the following code to export a datagrid to excel Public Sub ExportToExcel(ByVal dt As DataTable) Try Dim oApp As New Excel.Application Dim oBook As Excel.Workbook =...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.