Converting a List to a datatable

Hi guys,

I have a workflow with a List that I am trying to convert to a data table so that I can upload it to an Excel file. I want it to upload and append into the first column of the excel doc. I’m wondering what the best way to do this would be. I read that using the Build Data Table activity could be used but I am wondering if I can still use that if the input List is variable in size meaning there is a different amount of strings stored in the list. Any help is greatly appreciated!

Thanks!

If your list is not too big , create a new data table and you can process each element of the list in a for each loop and do add data row activity in the loop

Just so I understand, you have an existing excel file, and a list of strings (number of strings in list is variable). You want to open the excel file, then append each string in the list to the first column. Is that correct?

Use a build table activity with one column (of type string) and no data. Then use a for each activity (of type string) to iterate through your list of strings. Within the for each loop, use an add data row activity to add the current item in list to the datatable

Yep that’s correct.

I think what I need to know is what the datarow property of the add data row activity should be. If I try making it the current item in the for each loop it says it will not compile because item is of type of String while the input property needs a datarow object. I need to know how to convert the current item from the list into a datarow so that I can add it to the datatable

In the ArrayRow property of ‘Add Data Row’ activity, just supply the single string as an array,designated by curly braces {}

So it should be {item} in the ArrayRow property (or whatever you named the for each variable)

4 Likes

Awesome that worked thankyou!

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