Add row at end of DataTable

Hello friends,

@Rammohan91, @balupad14, @Gouda_6, @Florent_Salendres, @ClaytonM, @vvaidya, @Palaniyappan

I need to cycle over a collection of transaction.
At the end of each transaction I need to add a row to the Output DataTable and write it in an Excel file.
The action of “Add row” and “Write to Excel” must be done for every transaction.

Can you please help me in defining a sample workflow?
It’s very urgent for the development of a Bot at the client.
Thank you so much,
Cami :slight_smile:

1 Like

Hi @CamiCat

Great,

  1. Lets say you have a datatable read from a excel with excel application scope followed by read range activity or if you dont have a datatable use build datatable activity to build a datatable of your own structure…as simple as it is…
  2. Then to iterate through the collection of transaction, use a for each loop with that collection as input (not for each row loop, as you cannot add datarow to table when it is iterated)
    3.Once the transaction is over as you wish to add a row to the datatable created or having already can be done with the help of “Add data row”…HOW…?
  3. So in add data row, if you have a array of datarow {“value1”,“value2”} or even the collection you have or just a datarow from datatable like out_dt.Rows(Rowindex), give that as input to the add data row and here comes the answer for you…for input property of datarow in add data row, mention as out_dt.NewRow
    This would add new datarow to your datatable.
  4. Then with write range activity, you can enter the datatable to the excel you want
  5. Thats all buddy…you are all done…

Here is your workflow
Adddatarow.xaml (11.4 KB)

Hope this would help you

Cheers…

4 Likes

Thank you so mucj @Palaniyappan.
For adding an array as datarow, is it compulsory to insert also the out_dt.NewRow in the ArrayRow property?
Thank you so much,
Cami

1 Like

Fine @CamiCat
Not necessary, if you have the datarow or a array of row ready with you, you can give that as input to add data row activity
or
If you dont have any datarow with you just to add a fresh datarow of same structure in the datatable you can use out_dt.NewRow and then fill with details later you want

Hope this would help you…

Cheers

1 Like

It seems overwriting the existing row.
How to ensure it adds at the end?
Thank you,
Cami :slight_smile:

@CamiCat

Here is the sample workflow for you…
add_datarow.xaml (7.6 KB)

EDIT :slight_smile: Better with this xaml
add_datarow.xaml (8.8 KB)

Hope this would help you

Cheers…

2 Likes

Is that working…
@CamiCat

1 Like

Thank you so so much @Palaniyappan for your precious help.
It’s very kind from you.
Cami :slight_smile:

1 Like

Cheers…@CamiCat

Keep going…

1 Like

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