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

Home Posts Topics Members FAQ

Export data from datagrid to Excel

1 New Member
Hi

I am doing an application in which the search results are made to be displayed on datagrid. Now I should have the same results to be exported to excel sheet.

Can anyone guide me in this. My application is window based using C# .Net and Oracle database.
Jul 5 '07 #1
1 1072
c83
24 New Member
Hi

I am doing an application in which the search results are made to be displayed on datagrid. Now I should have the same results to be exported to excel sheet.

Can anyone guide me in this. My application is window based using C# .Net and Oracle database.
This si called Office Automation, google this and you will find a lot of results.

First you must add a com reference to your project - Microsoft Excel 11.0 Object Library (or other version).
And here is a piece of code of mine:
Expand|Select|Wrap|Line Numbers
  1. Excel.Application app = null;              
  2. // change culture information for the current thread  
  3. System.Globalization.CultureInfo oldCI = System.Threading.Thread.CurrentThread.CurrentCulture;  System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");         
  4.   app = new Excel.Application();      
  5. app.Visible = false;      
  6. app.DisplayAlerts = false;  
  7.     Excel.Workbooks books = app.Workbooks;      
  8. Excel.Workbook book = (Excel.Workbook) books.Add("templ.xlt");
  9.      Excel.Worksheet sheet = (Excel.Worksheet)book.Worksheets[1];
Jul 6 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: sunilkumar Reddy via DotNetMonster.com | last post by:
hai all first we can take binded grid Export to excel data from ultrawebgrid (or) datagrid rows, Each row data Expoting to one worksheet in excel workbook, like as grid row1 data contain sheet1...
6
by: Eric | last post by:
Dear All, I want to export datagrid content to a Excel file, the code just like below: Response.ContentType = "application/vnd.ms-excel" Response.Charset = "" Me.EnableViewState = False Dim...
2
by: Bidarkota | last post by:
Hi, I have a DataGrid in which there are some images and Data are displayed and in the webform.asp page i am using some stylesheets. when i export the datagrid all the images are also exported...
0
by: sunilkumar Reddy via DotNetMonster.com | last post by:
hai all first we have taken binded grid Export to excel data from ultrawebgrid (or) datagrid rows, Each row data Expoting to one worksheet in excel workbook, like as grid row1 data contain...
6
by: Sridhar | last post by:
Hi, I have to export data inside the datagrid into an excel worksheet. I have to do this on button click event. I am trying to do like this. First get the DataTable from the datagrid and...
4
by: Frank | last post by:
Hello All, I ham using VS.NET 2003. Have followed instructions from http://gridviewguy.com/ArticleDetails.aspx?articleID=26 along with several other articles to no avail. I am pulling my hair...
7
by: mattmerc | last post by:
Hi all, We have all seen lot of method for exporting datagrids to Excel. I have a slightly different need. I think it should be easy to accomplish but I am not sure how. I would like when a user...
4
by: amitmnagarwal | last post by:
I have a page where i export to excel the content of Page 1 following code is written on page 2 to generate the excel Response.Buffer = True Response.ContentType = "application/vnd.ms-excel"...
19
by: cj2 | last post by:
#1 Is there a quick way to export a datatable to an excel file? Or delimited file? #2 Where is the appropriate Microsoft monitored group to ask about writing reports in SQL Reporting services...
5
by: Reggie | last post by:
Hi and TIA! I have an export procedure that exports my data from my datagrids to excel. The problem is that I lose leading zero's cause excel removes them and doesn't treat them as text. Is it...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
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 project—planning, coding, testing,...
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: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.