Insert a new line without overwrite the record

I have a workflow that populates a result into an excel sheet.
I want to populate the new result into a new line in the same excel sheet every time the workflow runs.
For example:
I have no idea how it can be done. I appreciate it a lot if someone can help me with this.

Here is my xaml:

Hi @Lau_Wei_Ting

Have you try to use Append Range activity to implement that?

1 Like

Hey @Lau_Wei_Ting

You can do this very easily by using the append range activity. For this you dont need to specify the next a available row or anything. Just the activity and pass the datatable which you want to write and it will take care of it on it’s own… :slight_smile:


You can use Append Range activity if it is DataTable. Then it will add data at the end of the data without overwriting existing data.

Else if you want to add single row then you have to follow below steps.

  1. Use Read Range activity to read data from Excel file and will give you output as DataTable and say ‘inputDT’.

  2. And then find the row count like below.

     int count = inputDT.Rows.Count
  3. And then use Write Cell activity and pass values like this.

Range: “A”+(count+1).Tostring
Range: “B”+(count+1).Tostring

Just a quick question here.
If I want to display the header, is there any way to do it as Append Range activities does not have the “AddHeader” option.
If I use Append Range activities at the same time displaying the header, how should I do?


You want to append data to already existing data right. So why you want to add headers again. It’s no need. Just give it a try once.

By using the Append Range activities I am able to get what I want in which the data is not been overwritten. :blush:
However, if I want to get the header as well, is there a way of doing it?
currently, the result is like this:

Hello @Lau_Wei_Ting

you can use try catch activity for this, like below…

Kindly do not go for syntax

dt Dummy = New DataTable()
dtDummy = wb.ReadRange("Sheet1")
use append range activity here

Note: if sheet already have data only then read range activity will work else if there is no data in Sheet then Read range activity will fail and it will be catch in catch section

use write range activity here

Thanks for all your reply!!!
I got what I want!!!

1 Like

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