Hello,
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,
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
Assign:
CurrentDate = DateTime.Now.ToString(“yyyyMMdd”);
Assign:
MergedDataTable = DataTable1.Copy();
MergedDataTable.Merge(DataTable2);
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!!!
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
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
Excel.Sheet("Sheet1").Range("A"+CStr(rowscount+1))
@chandrakala.productanalys
write range activity.