Click here to Skip to main content
15,880,392 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?
Posted

1 solution

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.
 
Share this answer
 
Comments
wizardzz 8-Feb-11 16:52pm    
I will give this method a try. I have done import and export directly from CSV or excel files and it worked quite well, I don't have as much experience with handling clipboard though.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900