将DataGridView的内容复制到excel中 [英] Copy the contents of a DataGridView in to excel

查看:271
本文介绍了将DataGridView的内容复制到excel中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了一些示例,了解如何从一个数据网格视图,但是那些只是创建文件。我想要做的是具有未开放的工作表,并且在按下导出到Excel按钮后将数据网格视图(包括标题名称)的内容粘贴到工作表中。

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.

基本上,我想自动执行从数据网格视图到Excel的复制和粘贴时会发生什么。任何有关如何做到这一点的建议?

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?

推荐答案

看看本教程, http://www.gemboxsoftware.com/LA/Import-Export-DataGrid -XLS-XLSX-CSV-HTML-.NET.htm 。它显示了如何从datagrid导出生成excel文档。然后,您可以打开将以excel打开的文档。我不完全确定将其粘贴到当前打开的excel文档中,但这应该让你关闭。

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.

这篇关于将DataGridView的内容复制到excel中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆