| Author: Abhishek Arya 14 Jul 2006 | Member Level: Diamond | Rating:  Points: 2 |
use this code
Include Microsoft Excel 10.0 Object Library from Com components to your project reference. In this code ticketsList is a data set which is populated and shown in a grid. Hope this is helpful. Excel.ApplicationClass excel = new Excel.ApplicationClass(); excel.Application.Workbooks.Add(true); DataTable table = ticketsList.Tables[0]; int cIndex = 0; foreach(DataColumn col in table.Columns) { cIndex++; excel.Cells[1,cIndex]=col.ColumnName; } int rIndex=0; foreach(DataRow row in table.Rows) { rIndex++; cIndex=0; foreach(DataColumn col in table.Columns) { cIndex++; excel.Cells[rIndex+1,cIndex] = row[col.ColumnName].ToString(); } } excel.Save("New.xls");
|
| Author: ali udmilov 20 Aug 2007 | Member Level: Bronze | Rating:  Points: 2 |
:) Now you can use the DataGridView Extension. With its help you can export to Excel, Html ... soon pdf. Also you can search for text in the grid, theme managment and many more... find it on http://www.completit.com/Products/DGVE/Overview.aspx
|