DataTable Clone test

Hi if I clone a datatable, should I be able to write the range and see the headers of the clone table? Having trouble with this activity.
Using Assign: dt1 = dt2.Clone

Hi @dgreen

Instead of Clone, Try Copy

Mark as solution if this helps


Hi @dgreen

If you want to store the same dt2 in dt1 then do as below :-

DataTable dt1 = dt2.Copy

And you can use Write Range Activity to Write the Datatable i.e., dt1 to Excel.

Also to read column Headers for that DataTable then you can do below code :-


Dim name(DT.Columns.Count) As String
Dim i As Integer = 0
For Each column As DataColumn In DT.Columns
  name(i) = column.ColumnName
  i += 1

Mark as solution and like it if this helps you :slight_smile:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

I am ok with Clone as long as it works. What I’d like to know, if clone is successful, I should be able to write the table and see the headers, correct? I am getting an invalid object when trying to use the cloned table so the reason for me wanting to test.