Did you reference the Config and InitAllSettings.xaml which you can get by starting a new project using the “Robotic Enterprise Framework”. The InitAllSettings file gives an example on how to return a dictionary back with the settings.
To add (and this is just my preference), I recommend dynamically looping the sheets, so it can be more flexible on what sheets are contained in the spreadsheet rather than hardcoding the sheet names. You can get the sheets with a WorkBook application variable (using the Excel Scope) with wb.GetSheets. -Then, you can remove that argument. However, that depends on your preference I suppose. -The two main problems I have with the InitAllSettings is that it doesn’t use an Excel Read Range (Workbook Read Range requires the file to be closed) and that it requires that you give it the sheet names.
Hi @Gagi77 if the goal is to have these three values accessible at once, a Dictionary pairing might not be best. A better use for a config file with Dictionary type is typically a key value, and a second one associated with it. Your current Dictionary won’t allow you to have a second column value associated with your key value.
For your example here I would use the following:
Read range activity. Pass this into a normal DataTable variable.
Use the “Lookup” activity from the DataTable category. This will allow you to return the values from Column B and C more easily by manipulating the “Target Column” section to get the desired value from either B or C.
I noticed you have 3 columns in your config. So are you wanting something that results in something like this: Config("dept1")("sect1").ToString
where it is a 2 dimensional dictionary and you reference the Name using 2 keys rather than 1? If so, you might need to use a type of Dictionary<of String, dictionary<of String, object>>
This just requires that when you initialize the dictionary, you use something like this: new Dictionary(of String, new Dictionary(of String, object) )
Then, when you assign the value, outConfigFile(row("Department").ToString)(row("Sector").ToString) = row("Name").toString.Trim
and, if you actually have 4 columns, then you need to make it 3 dimensions.
type: Dictionary<of String, dictionary<of String, dictionary<of String, object>>>
assign: outConfig = new Dictionary(of String, new Dictionary(of String, new Dictionary(of String, object) ) )
assign inside loop: outConfigFile(row("Department").ToString)(row("Sector").ToString)(row("Name").ToString) = row("Value").ToString.Trim