How to append the data into excel using Add Data row activity

I have been trying to append the datarow value into the Excel file, But getting stuck while adding the rows in the Add Datarow activity.
The values of column3 is multiple in case of some of the transaction. As i am using for each loop to get the values,
But i am not getting how to write the values in column 3 so that for next transaction the row must start from the end of Column3

Please refer to the output expected Excel file :

image

Hi @mayankjha986 ,

When you use Add Data Row it is adding row by row. So you can give blank(" ") value for the columns which don’t have the value.

Eg; (" ", " ", " ",“Kolkota”, " “,” “,” ")

You don’t use Add Data Row to write to Excel. Add Data Row is for adding a row to a datatable. If you want to write to Excel, use the Excel activities - Write Row, Write Range, Append Range etc.

@mayankjha986 May I know why you are adding rows and then inserting data into the datarow. You can also read the whole data into a data table directly with the same format

@ushu , I am getting all these values from an web application , getting rest of the values using get text activity and string the values in a variable, and for col3, Extracting the Table and iterating over each row using for each loop, All the variable are being exported to data row correctly but for col3 getting the last row value from the loop.

Is there any way where i can store all the values from the loop in an array / list and can store the value in the last into add datarow as expected

@postwick is correct, “Add Data row” is for Data Tables stored in UiPath. Are you using “Read Range” to store the data in a data table? That would be required to use “Add Data row”.

@mayankjha986 Can you share the screenshot of how the col3 extracted table looks like that you are getting from the web application

Is there any way where i can store all the values from the loop in an array / list and can store the value in the last into add datarow as expected

Use “Build Data Table”
Use “Add Data row” to add your found values to the data table you just built
Use “Append Range” to append that data table to your excel file

@ushu Please find the sample xaml file.
DataTablesAndExcel.xaml (14.0 KB)

Need your suggestion how i can get all the values from a foreach loop in the datarow activity.

@ushu

Please find the updated sample XAML file.
DataTablesAndExcel.xaml (15.8 KB)

@mayankjha986 Please share excel file with few sample rows

@ushu Please find the Sample Excel file

Data.xlsx (9.8 KB)

@mayankjha986 Please find the below workflow where it read the data from an excel and updates same in the ouput excel

DataTable.zip (19.9 KB)

@ushu Thanks for the answer.
In the given workflow file only the data from excel has been appended,
i am expecting to get the city column value from the Excel into an Array, inside an for each loop, which can be exported to datarow in an separate rows for each Transaction.

Alongwith the other variable values.
Need your suggestion