How to append 2 datatables into single excel sheet with headers


I am attempting to merge two datatables into a single sheet with headers and the current date. I utilized the Append Range workbook, but it doesn’t preserve headers for the second datatable during the appending process

Hello @chandrakala.productanalys

CurrentDate = DateTime.Now.ToString(“yyyyMMdd”);

MergedDataTable = DataTable1.Copy();

Invoke Method:
TargetObject: MergedDataTable.Columns
MethodName: Add
Parameters: “Date”, typeof(string)).DefaultValue = CurrentDate;

Excel Application Scope:
Write Range activity to write MergedDataTable to the desired sheet.
Set “Add Headers” property to True.

Thanks & Cheers!!!

Hi @chandrakala.productanalys

You can use Write Range for Each DataTable:
Instead of using Append Range, use Write Range separately for each DataTable. Write the first DataTable to the Excel sheet, then write the second DataTable starting from the another row to preserve headers.

Hope this helps :slight_smile:


Can take 2 write range activities
For second Dt give the cell range as row count + 3 of first Dt
I have share the screenshots please check



if you can use modern activities then you can use append range activity in which you will get the headers as well

How to write the header’s with write cell activity.I tried it showing error Write Cell: The range does not exist.

It has to append second dt after the last row of first dt.


rowscount is of int32 datatype


write range activity.