1

I am creating a UI Path bot and using the Excel Read column activity to read contents of a column. I want to use this as text to use somewhere down the line but now the Excel read Column activity outputs an IEnmerable(Object) and I want to pass this to a variable that is a string. So far I am getting an error when I use the following:

myTextString = CType(myIEnumerableObject, String)

or

myTextString = myIEnumerableObject.ToString  (this is simply stored as System.Object)

or

myTextString = CStr(myIEnumerableObject)

What I need is to be able to convert this object to a string, store it in a string variable and be able to re-use it later.

Thanks

Cindy Meister
  • 25,071
  • 21
  • 34
  • 43
  • Just a correction for my second alternative attempt myTextString = ```myIEnumerableObject.ToString (this is simply stored as a string "System.Object")``` – Sinethemba Nontshintshi May 20 '19 at 09:55
  • Do you want each cell in the column to be a separate string or the entire column represented as a single string? – Mads T May 20 '19 at 10:28
  • I want the entire column as one big string. – Sinethemba Nontshintshi May 20 '19 at 11:12
  • Can you add 3rd party libraries in UIPath? If so, try and serialize it using the Newtonsoft.Json library. – Skin May 20 '19 at 11:19
  • This is NOT VBA code. VB.NET, I'm guessing? Please take care when tagging questinos to use the correct tags, otherwise you won't reach the right people. I'm removing the VBA tags, but you'll want to [edit] to add the correct programming language tags. *READ the tag INFO* before choosing a tag! – Cindy Meister May 20 '19 at 11:29

2 Answers2

1

You want to use String.Join(<seperator>,myIEnumerableObject) in an Assign activity, where <seperator> specifies the seperator between each element in your IEnumerable:

String.Join(",",myIEnumerableObject) provides a comma separated string.

Mads T
  • 530
  • 3
  • 14
0

You can read the data with a Read Range activity (specifying range to your desired column or not) , in that way you can store the data in a DataTable variable and access the column directly by name with mydatatable.Columns.Item("mycolumn"). It's easier and doesn't require additional coding.

JaviL
  • 102
  • 1
  • 7