How to get DataTable from Dictionary<String,Object> entry

Hi,

I’m using a Dictionary(Of String, Object) to pass data within my automation. I’m scraping a table from a web page and I save the DataTable as an entry in a Dictionary like: myOutputDictionary("Table") = theDataTable

How can I get back the DataTable from the dictionary in order to use it in a WriteRange Excel activity?

myOutputDictionary("Table") returns an Object, how do I cast it to DataTable?

Thank you in advance

I’m waiting to see what others have to offer for your question. But if all that you do from reading the DT name from dictionary is just to write to excel, why can’t that be done prior to inserting DT into myOutputDictionary? Not only it simplifies, but it also saves you the extra trouble of reading from the dictionary and casting it.

@pedro.arroyo
give a try on DirectCast( myOutputDictionary(“Table”) ),DataTable)

6 Likes

Thank you!! That made the trick :wink:

It surely simplifies the problem in the sense that I don’t have to deal with the conversion down the line, but in terms of project structure, the interaction with the web page happens two or three steps above the creation and population of the excel file.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.