开发者

Copy the contents of a DataGridView in to excel

开发者 https://www.devze.com 2023-01-12 19:00 出处:网络
I found some examples of h开发者_如何学Cow 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 h

I found some examples of h开发者_如何学Cow 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号