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:


Hi @andrzej.kniola

If I don’t use “ToArray()” then I am getting the output as “System.Text.RegularExpressions.MatchCollection”


if I use “ToArray()” then I’m getting an error as “ToArray is not a member of System.Text.RegularExpressions.MatchCollection”

Can you please help me with this?

I have a variable of type MatchCollection and need to convert it into a string with all its values separated by “;”


with matches as your MatchCollection, the following should work:

Assign (String)
strMatches = String.Join(";", matches.OfType(Of Match).Select(Function(m) m.Value.ToString))

as an extra, here how you could obtain an arrray of strings from your MatchCollection

Assign (Array of String)
arrMatches = matches.OfType(Of Match).Select(Function(m) m.Value.ToString).ToArray

EDIT: as andrzej.kniola noticed, .ToString is applied to all elements in the concatenation. The following will produce the same string:

Assign (String)
strMatches = String.Join(";", matches.OfType(Of Match).Select(Function(m) m.Value))



That worked perfectly fine. :slightly_smiling_face:

Thanks a lot for providing this solution @msan


I have used exactly the same. But it throws error “OF TYPE IS NOT A MEMBER OF MATCHES”

Hi, check that the variable matches is a MatchCollection instance. Maybe using a different variable name can help avoiding a clash with an imported class.