I have an excel spreadsheet, that contains client information. I would like to populate a combo box (comboBox1) with unique values from Column A. I would then like a second combo box (comboBox2) to list the values from Column B that exist where comboBox1=Column A. Finally, I would like to populate text fields with column’s C, D, E and so on….
I have mocked up a quick screen of my desired result:
This would be derived from the following spreadsheet:
The data in the spreadsheet changes from time to time, which is why I can not hard code the information.
I am not sure where to even start with this. Do I load the data into 2D arrays or is there a better way of doing it?
You have at least a few options.
If the excel file is a 2007 format (xlsx) or up, then you can work with it programatically via the OOXml SDK provided by Microsoft.
Have a look at the following How-To:
For other How-To’s for spreadsheets:
You can automate excel and interact with it programmatically. This requires excel to be installed on the computer the program is running from. Microsoft also cautions that this is not supported on server environments.
There are many questions on SO about excel interop via C#.