如何将 ASP.NET GridView 复制到剪贴板
有谁有将 GridView/Datatable(Web 应用程序 aspx)的内容复制到剪贴板的解决方案/链接,以便我可以粘贴到 Excel 中?
我尝试四处搜索,但只找到了表单应用程序的解决方案。
Does anyone have a solution/link for copying contents of a GridView/Datatable (web application aspx)to the clipboard, so that I can paste inside Excel?
I've tried searching around but only found solutions for a Forms application.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这里有一些代码可以帮助您将网格视图的数据放入剪贴板,以便您可以粘贴到 Excel 中。
Here's some code to help you guys out with putting a grid view's data into the clipboard, which lets you paste into Excel.
将内容复制到剪贴板的唯一可靠方法是使用 Flash Player。这是一个开始:
http://beckelman.net/post/2009/01/22/Copy-to-Clipboard-with-ZeroClipboard-Flash-10-and-jQuery.aspx
The only reliable way to copy stuff to the clipboard is to use the Flash Player. Here's a start:
http://beckelman.net/post/2009/01/22/Copy-to-Clipboard-with-ZeroClipboard-Flash-10-and-jQuery.aspx
听起来您对 gridview 感到困惑。和你所描述的没有任何关系。您需要谷歌一下如何使用 C# 将数据导出到 Excel。您可以创建一个链接或按钮,显示下载 excel 文件,该按钮将绑定到您的 c# 方法。如果您在整个网站上使用此方法,您可以执行一次,并可能使其使用参数来确定要将哪个数据库表导出到 Excel。
Ps 如果您正在寻找比 gridview 更多的功能,我建议您看看我对这篇关于创建您自己的文章的回答。 如何在每个 gridview 行项目上显示 gridview 中数据库的弹出菜单?
您绝对需要将其复制到剪贴板吗?也许可以做到这一点,但需要大量编码。您正在谈论将数据粘贴到多个字段而不是一个字段中。我想你必须为 Excel 创建一个扩展,它知道剪贴板数据来自数据库表并弄清楚如何填充工作表。
It sounds like you are confused about the gridview. It has nothing to do with what you are describing. You need to google how to export data to excel with C#. You could create a link or button that says download excel file and the button would be tied to your c# method. If you use this method across your website you could make it once and possibly make it use a parameter to figure out which database table it is exporting to excel.
P.s. In case you are looking for more functionality than the gridview I suggest you take a look at my answer to this post about creating your own. How to show pop up menu from database in gridview on each gridview row items?
Do you absolutely need to copy this to the clipboard? It's probably possible to do this but would take a lot coding. You are talking about pasting data into multiple fields rather than in one field. I imagine you would have to create an extension for excel that would know that the clipboard data is from database table and figure out how to populate the sheet.