Add new rows to the TOP of datatable

Hi,

My current automation tries to process an excel sheet - deleting some rows and outputing a new treated sheet.
At the moment, I can output the new sheet without the rows I deleted but in the process I lost the original header so I am trying to add the original header to the top of my new sheet.

[I even managed to output the processed sheet with the header at the bottom]

I figured the simplest way of accomplishing that would be creating dt3 and merging the header and all others rows I have in a previous processed datatable.
However, I am struggling to add the header to the new datable (dt3).

This is how I am doing:

  • I get only the header from my original sheet into an array of DataRows called “Header”.
    [I’ve printed it out on log and it displays the right rows]

  • I try to add the rows from array Header into the new datatable (dt3). I’ve tried using Add data row - which brings me a message the rows is already in another datable. And I’ve tried using ImportRow (invoke method) - which doesn’t pop up any erros but doens’t fill my new table as well.

Creating new table:

image

Trying to add header to new table:

image

Output:

image

Any thoughts on that?

I have solved it.
The problem was the way I was initiliazing the datatable.

It can be deleted.

Thks.

for this error you can use like this

Regards
Balamurugan

2 Likes

Hi I am struggling with the same problem that it won’t print out just one row in a new table (in this case header)…
Could you please send me your code or explain me how to copy the header in the datatable?
Thank you!