How to populate array from excel file

Hi,
I need to insert data into array of string. In my example, I have one excel file with three column (A, B and C). I need to get data from A2 and insert into array ( thinks with double quote “” and comma , to separate value into array). I need to do the same thing for column B (in other array) and C (in other array). I do this in this way:

I read excel with read range activity and store value in DataTable, then I create a string variable (like VariableA) and with assign activiy I do this:

VariableA = string.Join(“,”,DataTableConfigurazioneRobot.AsEnumerable().[Select](Function(s) s.Field(Of String)(“Username”)).ToArray()).

Now, I create ArrayA and i set it in this way:

ArrayA = {VariableA}.

But when I read arrayA, uipath read full string like unique string in variableA (also if the data are stored with double quote and comma {“Data1”,“Data2”, “Data3”, etc…}.

How can I do to insert values in correct way in array?

I hope I have explained the problem correctly

Thank you all,
Andrea.

@andrea.mario,

This query already returns Array(of string)

Can you elaborate with examples ?

Regards,
Dominic :slight_smile:

@andrea.mario
VariableA = string.Join(“,”,DataTableConfigurazioneRobot.AsEnumerable().[Select](Function(s) s.Field(Of String)(“Username”)).ToArray())

In this Query you need not join the elements of the array.

DataTableConfigurazioneRobot.AsEnumerable().[Select](Function(s) s.Field(Of String)(“Username”)- This Query will return an Array.
If U want to add any new elements to the array you can use Add To Collections Activity.

Regards
Mahesh.

Hi,
Thank you for your response.
I need to get value from excel and I need to insert this value in array. Then I have to do a cycle (While) to scroll element in array.

It is possibile?

Thank you.
Andrea.

@andrea.mario,

Of course it’s possible. And you have a solution with you. Following query does it.
DataTableConfigurazioneRobot.AsEnumerable().[Select](Function(s) s.Field(Of String)(“Username”)).ToArray()

For each while activities can be used.
Regards,
Dominic :slight_smile:

@andrea.mario

1.Yes it’s Possible, Once after you extracted the Column of Excel sheet to an array, if you want to add any new elements then add by using Add to collections activity.
2.If you want access each and every element of that array, then use for each activity.
3. Inside for each you can give your condition according to the requirement.

Regards,
Mahesh.

Thank you all,
now it works.

Andrea.