Drop an Excel spreadsheet into a Windows form

Good morning. I would like to drop an Excel spreadsheet in one of my Windows forms. Is this possible?  If so; please guide me through it. If it makes any difference, I am running Visual Studio on a Windows 8, 64 bit PC.  Thank you for any help.  --  Joe
jampostGeneral MaanagerAsked:
Who is Participating?
frankhelkConnect With a Mentor Commented:
Sorry, no, you've misunderstood that.

The VS forms are able to receive events when an object is dragged and dropped. When the events are fired, the event handler routine gives you an object whith properties who allow you to determine the type of the object, the allowed actions, and some more things. If a file is dropped, it allows you i.e. to get the file name.

After that point you're simply on your own, means that if an Excel file is dropped, you have to extract the info about it from the object, open that file with whatever code you have at hand and transfer the data into a standard data structure which lets you work on it further down the road.

There are surely methods for accessing Excel files from VB, but you have to call them yourself and extract the data with them.

But don't forget to check first what you've got dropped in ... if it's not an Excel file, but an image, a clipboard snippet, an executable file, or whatever could be dropped, your interpretation code will fail.

Please have a look at these examples:




Windows Forms provide the following events for Drag&Drop operation:

DragEnter, DragDrop, DragLeave

The precise meanings are explained in the VisualStudio help, usually along with examples.

DragEnter is fired, when an object is drawn onto the form's area, and DragLeave when it is subsequently drawn outside - these might be used i.e. for changing the cursor shape. DragDrop is fired when the object is dropped onto the form.

When an event handler routine is called, it gets some arguments with information about the handled object (and some more things).

What you have to do is to analyze what had been dropped onto the form and take the correct actions. There's no predefined Drag&Drop interface for a specific dropped object type - you only get the info that something has been dropped onto your form and where to find the object data (i.e. file, clipboard content, image, any kind of object). You have to handle the access to the object on your own (even while surely some data handling is built in, but you have to code what is to be done).
jampostGeneral MaanagerAuthor Commented:

So you are saying that the Visual Studio "Toolbox" has a functional spreadsheet that can be added to a Windows form?
jampostGeneral MaanagerAuthor Commented:
Thank you,  I'll find a work around for this.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.