C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Exporting DataGrid Data to Excel in Windows Applications


Posted Date: 31 Jul 2006    Resource Type: Articles    Category: .NET Framework
Author: chaitanya PrathimaMember Level: Silver    
Rating: Points: 8




Excel.ApplicationClass excel = new Excel.ApplicationClass();

excel.Application.Workbooks.Add(true);
System.Data.DataTable table = ds.Tables[0];
int ColumnIndex=0;
foreach(DataColumn col in table.Columns)
{
ColumnIndex++;
excel.Cells[1,ColumnIndex]=col.ColumnName;
}
int rowIndex=0;
foreach(DataRow row in table.Rows)
{
rowIndex++;
ColumnIndex=0;
foreach(DataColumn col in table.Columns)
{
ColumnIndex++;
excel.Cells[rowIndex+1,ColumnIndex]=row[col.ColumnName].ToString();
}





Responses

Author: SRIDHAR    21 Mar 2007Member Level: Bronze   Points : 0
i would like to say very thks to this article's author.. it will be helpful for so many software guys...


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: What is ADO.NET?
Previous Resource: Create RSS From Database for subscribe
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use