将Excel表复制/粘贴到GridView [英] Copy/Paste Excel Table to GridView

查看:153
本文介绍了将Excel表复制/粘贴到GridView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始研究一个excel程序,该程序调用了一些代码以将一堆行插入到SQL表中.它使用了未记录的VB宏,并且由于其他原因,我决定将功能重写为独立的GUI应用程序.

我停留在一个初始点上.主控件是一个具有15行的GridView(每行最初仅在最左侧的列中包含一个标识符名称).有什么方法可以允许用户将excel表或电子邮件中的excel表之类的数据直接复制并粘贴到GridView中?我想我可以让用户粘贴到TextBox中并简单地对其进行解析.

如果只有第三方控制才可能做到这一点,那么有人知道哪个第三方控制允许吗?

I started working on an excel program that called some code to insert a bunch of rows into a SQL table. It uses undocumented VB macros, and for other reasons, I have decided to rewrite the functionality as a stand alone GUI application.

I am stuck on one initial point. The main control is a GridView with 15 rows (each row initially only contains an identifier name in the left most column). Is there any way to allow the user to copy and paste data from an excel table, or excel like table in an e-mail, directly into the GridView? I suppose I can have the user paste into a TextBox and simply parse it.

If this is only possible with 3rd party controls, is anyone aware of which 3rd party controls allow it?

推荐答案



在网格视图上,您​​可能会弹出菜单,说粘贴".从excel复制后,内容将在剪贴板中可用.然后右键单击并选择粘贴,该粘贴将实际读取剪贴板数据,对其进行格式化并填充网格视图.

您可以参考这篇文章使用.NET进行剪贴板处理 [
Hi,

On your grid view you may have pop up menu say "Paste". Once you copy from excel the content is available in the clipboard. Then right click and select paste which will actually read the clipboard data, format it and populate the grid view.

you may refer to this article Clipboard handling with .NET[^] which explains how to handle clipboard data.

Format the clipboard string may be a bit hard as the strings may not have a data separator, but yet it is possible.

Export to csv and import option will be easy for coding, same time more work for the user.


这篇关于将Excel表复制/粘贴到GridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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