Question Interactivity with Excel

Invyktus

New member
Joined
Dec 1, 2009
Messages
2
Programming Experience
3-5
I have a form that silently interacts with Excel by adding cells based on user input. I completed the solution and it talks with Excel perfectly, updates the records and cells in Excel wonderfully. After completion, I sent the requesting user the completed product and he was happy.

The user wanted to know if there was any way to pull the data back into the form from Excel after it had been created, and then updated if need be. The way he was thinking this could happen would be to pull the "name" into a combo box and when a previously entered "name" was selected, the rest of the form would display the rest of the data from that "row" in Excel. (Hopefully I am explaining this clearly enough.)

It was challenging enough for me to be able to open and write to Excel in the first place, as I do not have the knowledge necessary to facilitate such a request.

Thank you in advance and feel free to critique or manipulate the code attached. I'm always looking for ways to improve.

Thanks again!
 

Attachments

  • code.doc
    40 KB · Views: 19

Tom

Well-known member
Joined
Aug 23, 2005
Messages
746
Programming Experience
5-10
Automating Excel gives you more flexibility and control of every cell but if the worksheets follow a consistent tabular format (same as a database table) using OLEDB you can import/export the data directly to/from a dataset/datatable without the need of automating Excel.
 

Invyktus

New member
Joined
Dec 1, 2009
Messages
2
Programming Experience
3-5
Thanks for the quick reply Tom. Unfortunately, I have no idea how to use OleDB.

Because I've previously automated Excel when adding data, is it possible to switch over to using OleDB in the middle like that?

Basically, on form_load I need the combo box to fill with the Names from the Excel "A" Column, and then when a user selects one of those names, I need the rest of the form to populate the corresponding data for editing.
 

Tom

Well-known member
Joined
Aug 23, 2005
Messages
746
Programming Experience
5-10
I dont know what your Excel sheet looks like but if it fits a tabular format as I mentioned, it is easy to read the data into a dataset and bind a selected column to a combobox.

If it does not fit a tabular format, you would need to automate Excel to read the values into a DataSet/DataTable.
 
Top Bottom