Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting DataGrid to MS Excel

Status
Not open for further replies.

rpk2006

Technical User
Apr 24, 2002
225
IN
I am displaying certain records in a DataGrid whose number of field display changes depending upon the fields the user want to select.

I want to EXPORT this whole DataGrid to MS Excel as it is. How to do so?

Since the number of field display changes, I cannot reserve the number of cells in Excel. So I want to transfer the Grid itself.
 
Might not be the best way but this but I could suggest that you loop through the datagrid, first adding the column headers and then the data using Excel automation. Might not be the fastest way but it does work (I've done something very simlilar before). Will work as long as you won't be returning more than the 65536 rows that Excel allows in a sheet.


Harleyquinn

---------------------------------
For tsunami relief donations
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top