views:

879

answers:

2

I need to Export DataGrids' Contents to Excel using VB.Net for a Window based Application.

How to do this.. any ideas ?

+1  A: 

The are plenty of ways to do this. Create the excel file using static methods in the File class. Then you can create a OleDB connection to the excel file and then write all the data to it using SQL query.

danish
This just blew my mind. I'm the idiot that uses the .net interop classes and writes the data out row by row, column by column. :(
tom.dietrich
A: 

Out of the box DataGrid doesn't support this feature. You can a. Use a third party data grid that has this feature b. Create a report that have the same contents as the grid. Report Viewer control that is freely available from Microsoft has the feature to export to Excel

Ender