How to convert IEnumerable object type to Data table or String?




I am trying to copy a column data from an excel sheet to the clipboard and paste the same data onto a work space. I have used the “Read column” function to read the respective column from excel and I saved the content to a reference variable with type “IEnumerable Object”(as it is only accepting this type).
I am unable to find a way using which I can convert this IEnumerable Object type to Data table or String so that I can paste the same in the desired work space??

Thanks in advance.


Having the same problem. #Bump


If you just want to convert your datatable to a string, one way is to use the Output Datatable activity, which outputs it to a comma-delimitted string. Then, you can set that text somewhere or use Set to Clipboard.



Simple way:
(outputDT has just one column of type String)


To String

stringColumn = string.Join(",", IEnumCol.ToArray() )


.ToArray() is not needed, it accepts an IEnumerable directly as well.

Interestingly it works irregardless of actual types in the collection and concatenates it’s .ToString() outputs. Didn’t know that :slight_smile: