Read data from a column and assign it to array of string

How get data from an excel column and assign it to the array of string

1 Like

Hello @Deep_Kumar
Welcome to our community

  1. use read range activity to read data from Excel and store in data table
  2. when data in data table then you manipulate data according to your need
    Thanks

Hello @Deep_Kumar

You can use Read Column activity to obtain column as IEnumerable. Then use ToArray method to obtain table of Object(s).

Hi @Deep_Kumar
You can do it in multiple way but the simplest ways is to If you know the Column name or column index then Just use the Read Column Activity its output will be the collection.

Hi @Deep_Kumar

Welcome to uipath community
–fine thats really a good question to start with
–use a excel application scope and pass the file path as input
–use read range activity and get the output with a variable of type datatable named outdt
–use a for each row loop and pass the above variable as input
–mean while create a variable of type list(string) named out_list with default value like this new list (of string) in the variable panel in studio bottom
–now inside the for each row loop and use a add to collection activity and mention the property like collection as out_list and item as row(“yourcolumnname”).ToString
–thats all, simple isn’t it, to know the values of the list collection use a for each loop next to the above for each row loop and pass the above variable out_list as input and change the type argument as string in the for each loop activity property panel
–inside this for each loop use a write line and pass the value as item as input and it will display the value in the list in the output panel
–the reason why we use list instead of array is we may not know how many to be saved as the index of array must be initialized in the very beginning itself and it might change in the middle, so it is advisable to use a list instead of array

hope this would help you
kindly try this and let know for any queries or clarification
cheers @Deep_Kumar

4 Likes

Here I have used array of string for reading specified columns of Excel. Declared variable cols and stored columns “A” and “B” to read these two columns using while loop. This helps in reading selected columns of excel. This string array helps me in defining the range in Read Cell activity “cols(y).ToString+x.ToString” where x is iteration variable and cols(y) starts with columns “A”. Here the images.

hello , could you please explain what to put in the collection property of add to collection activity?

in collection property we need to mention the collection variable
Cheers @Karan28

okay that will be the input for add to collection activity , but what value will get in that collection variable?

Its giving error

It worked for me thanks.

Great!Thanks. It Worked for me.