Write range from row.item

Hello everyone, is there any way to record data from row.item(“Reference”).toString
in the “Write Range” without creating a Data Table

If you have row.item you have a datatable. Looping through the datatable and writing each row and cell one at a time isn’t the right way to do this. Read everything into a datatable (which you already have) and then manipulate the data in the datatable to get it how you want it. Then Write Range to a spreadsheet.

The row.item is the result of a check and I need them in a new tab
How do I put all the information passed by row.item in a new table

Hi Rntss23,

If you are trying to create a new DataTable with simply one column from another DataTable, assign a new DataTable to this statement, where “DataTable” is your current DataTable and “columnName” is the column you wish to keep.

DataTable.AsDataView.ToTable(false, "columnName")

You will likely want to keep the primary key column for further processing, simply add the ID or primary key column name in “idColumnName”

DataTable.AsDataView.ToTable(false, "idColumnName", "columnName")

Kind Regards

Actually I just need to collect the data that goes through: row.item(“Reference”).toString

Somehow, either through a variable or a new datatable to then record them in an excel tab through the write range

I don’t know if I was clear in explaining the problem if I don’t let me know

You can simply write the entire column to the sheet instead of looping through the DataTable rows each time. Put the code I provided you directly into the Write Range activity, specify the column with the range.

If you provide screenshots of UiPath and your Excel sheet I can help you with a specific example.

Hi @Rntss23 ,

Please Provide your Inputs in the following manner to make us help you in a quick and a better way :

  1. Provide Input Data(if Confidential, Sample data ).
  2. Explain the Logic.
  3. Provide the Expected Output for the Sample data provided. (IMPORTANT)

Following the above pattern of Steps would help us to understand your query faster.

1-First step I enter the values ​​in the system collected “Referência” column
Using for Each row :slight_smile:

2-So I have a Check State that follows the workflow through the data (row.item(“Reference”).toString) inserted in “Type into”
with that I need the data of this workflow (in this case the data is contained in the row.item(“Reference”).toString

However, I need to save this data to write them in a specific tab in excel

Essentially you are logging the reference for each item that is successfully processed (If the Target Appears in Check App State), then writing this to an Excel sheet?

Exactly

Without seeing the Excel sheet I can’t offer my most specific recommendation, but:

  1. I would firstly build a DataTable at the start for processed items i.e. processedItemsDT with 1 column named Reference of type String

  2. In Target Appears sequence, I would use an Add To DataTable activity with value Row.Item(“Reference”).ToString

  3. Then after the For Each Row in DataTable sequence has finished (or when all items have been processed), I would use a Write Range activity with input processedItemsDT and StartingCell property the first cell of the desired column in the Excel sheet.

I would like to point out that your process is a transactional process so would be best suited to use the Robotic Enterprise Framework (REF) template. The REF can be adapted to use Tabular data as TransactionItems. This would bring greater error handling, and “robustness” to your process. If you want to check it out, please see:

The academy has a great tutorial on adapting the REF Framework to use Tabular Data (such as DataRows):

Hope that helps,

Che

Please can you illustrate using the suggested activity: 2.In Target Appears sequence, I would use an Add To DataTable activity with value Row.Item(“Reference”).ToString

Sorry, I meant Add Data Row activity, and add { Row.Item("Reference").ToString } in ArrayRow parameter, we must encapulsate this with curly brackets {} to signify an array.

Here is an example.

image

Kind Regards

1 Like

Wow it worked!!!
Very good !
Speechless !!
Thank you very much for your support and attention.
Success and thanks again brother

1 Like

No problem at all, I’m glad I could be of assistance.

Remember to check “Add Headers” on the Write Range if you wish to write Column name to Excel.

image

Happy automating
Che

2 Likes

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