I have a dictionary of the form : dictDatatables<String, DataTable>
I was able to add datatables to the dictionary and some testing shows they actually contain (the expected and correct amount of) rows.
But when I want to write the datatable to an Excel file, the file stays empty.
I use a regular “Write Range” activity. In that activity I use dictDatatables(“tablename as key”) as value and UiPath doesn’t complain about that. It accepts the input.
The whole thing runs fine. But when I open the resulting Excel fil (which does get created), it’s empty.
Better check it once by printing in OutputDataTable activity, whether it is having value or not
I did that and surprisingly it also turned up empty. Even though when I do a row count of one of the datatables inside the dictionary it matches up perfectly with the expectations. Also the dictionary contains the correct amount of datatables. So they get created and ImportRow works but it imports empty rows then?
Here’s what I’m doing
It’s just a for each activity on a datatable (which needs to be split into multiple datatables). I check in an if activity if a datatable already exists in the dictionary (using the key). If not, I create it and then do an ImportRow, if it does exist I only do an ImportRow.
Whenever you are using import row methos make sure that the original datatable and the datatable to which you are importing Schema should be same .
Is there some way I can copy the schema? I’m not sure how to give them the schema when I create them dynamically.
dt1 will get the only the structure from dt but not the data. that is it will get the schema.
and one more thing . I saw that you are initialising the DataTable. I think you should not do that there, because when ever you do that it will delete the previous data
I was successful by using a combination of datatable.clone to get the structure and then datatable.tablename to give it the required name.