views:

27

answers:

1

I found some examples of how to create a excel file from a data grid view, however those just create the file. What I would like to do is have excel open, with a unsaved worksheet, and have the content of the data grid view (including header names) pasted in to the worksheet after pressing a "Export to Excel" button.

Basically I want to automate what happens when you do a copy and paste from a data grid view in to excel. Any suggestions on how to do this?

A: 

Take a look at this tutorial, http://www.gemboxsoftware.com/LA/Import-Export-DataGrid-XLS-XLSX-CSV-HTML-.NET.htm. It shows how to generate an excel document from the datagrid export. You can then open the document which will open it in excel. I'm not entirely sure of a way to paste it into the currently open excel document but this should get you close.

Chuck Haines