How to convert every element in a data table into a string for use in a "Type into" activity

Dear UiPathers

I am working with a big data base which has a lot of information about firms and businesses. I have successfully extracted the data required into an Excel spreedsheet and saved the data into a data table called dt.

I now want to go into a website and enter every single element of my dt into the search bar on the website.

For simplicity, you may assume my dt is a 3x3 excel spreedsheet. You may also assume, that I have made a process that goes into the correct website (url). You may also assume that I have reached the point where the search bar is and automated the clicking process. Finally, you may also assume the data table is the amount of cells (3x3).

The problem I am facing is converting the indexes of dt into a string. For example, when manually doing dt(1).ToString I would expect the process to write 123456789 into the search bar on the website, but it does not. In return, it writes system.data.datarow which is not my desired output I am looking for.

Below are some posts which are similiar to my problem, but does not fix my issue. I want my process to sucessfully go through all of the elements inside the data table dt, convert them to string and then write every single element into the searchbar on the website as a string allowing the website to successfully look up the companies.

I have also posted some snippets of my workflow for anyone curious.


Have a great day/ night forward everyone!

Hi @nmjvk

For this you could use for each row in datatable
Then use currentrow(1). tostring to access the cell of each row.

Dear Sangeethaneelavannan1

Let’s assume I only have 1 element in my data table so no need to use a for loop. How would I manually convert that data table into a string, if I don’t want to use a for loop?

dt(1).ToString returns the 2nd row of the datatable
if you want the 1st column of 2nd row, you need to do this:

dt(1)(0).toString → this will give you the value of the 1st column of the 2nd row

To loop over each and every element, do the following:

  1. use foreach row in datatable activity to loop each row
  2. inside, use a foreach activity to loop each column, where the target is dt.Columns, and typeArgument = DataColumn (see screenshot below)
  3. finally in the foreach, you can have your type activity.
    The string to type will be
    CurrentRow(col.ColumnName).ToString

This will let it type each element of the datatable (it will be in this order:
row1, col1
row1, col2
row1, col3 and so on…

you can switch around the order by putting the for-each row in datatable activity inside the foreach column activity so that it will look like
row1, col1
row2, col1 and so on …

2 Likes

@nmjvk use output datatable activity to convert it to string

This right here is exactly what I am looking for. It works as a charm. Thank you very much sir @jack.chan. Have a wonderful day/ night forward!

2 Likes

thanks! good luck!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.