Writing data in excel from dictionary

Hi,
I need to write data in excel file from dictionary(key, value) both key and value are string type.

Conditions are,
My excel sheet already have some data.
I have to match key of a dictionary to excel header and write dictionary value into same column below the existing data.

thanks in advance

Hi
hope these steps would help you resolve this
–use a BUILD DATATABLE activity and create a datatable with similar column structure of your excel and get the output with a variable of type datatable named dt
–now use a FOR EACH activity and pass the dictionary variable as input and change the type argument as System.Collections.Generic.KeyValuePair<TKey, TValue>
–inside the loop use a add datarow activity and mention the array row property like this
{item.Key.ToString,item.Value.ToString}
assuming that we have only two columns

now after this FOR EACH loop we can use APPEND RANGE Activity inside EXCEL APPLICATION SCOPE and pass the filepath of excel as input so that it will append this datatable at the end

Cheers @amit.chaudhary

1 Like

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