Copy the row items into Datatables

I have a Data table(Dt) where the values are get from excel application, and I have a another data table (NewDt) which i declare manually. (Dt) Data table have multiple columns. No.of Columns in the Dt and NewDt are same but the column name differs.

I need to copy each and every row item into the (NewDt) Data table.

Can some one guide to do this.

Thanks in advance
(Jothyprasanth M)

Can you check below (not sure about result)

Read Range Dt (without Addheaders checked)

NewDt= Dt.Copy()

Write Range NewDt (with AddHeaders checked)

Hi @jothyprasanth.m

Refer the below workflow… I hope it will suffice your need
CopyDt.xaml (10.3 KB)

Regards
Karteek YVN

Nevermind, my solution will overwrite Columns , just wanted to see if we can avoid foreach loop.

you can go with @KarteekRPA 's solution.

Either something went off on my side, or you’re still using V7 compatibility activities (UiPath.Activities namespaces). If that is so, I’d highly recommend using new ones (from UiPath.Core).

I need to read multiple sheets in one excel and those values are write into another excel file

Hi @jothyprasanth.m

You can read two excels into datatables, use the logic I shared earlier & copy both the tables into one.
Then you can write the final output to anywhere.

Regards
Karteek YVN

Hi @KarteekRPA thank u for u r solution it is working great,

And i have one more doubt

Is it possible to Change the Column name in the output file while writing

Hi @jothyprasanth.m

Use assign activity to change column names in the datatable with below code.
dataTable.Columns(<ColumnIndex / ColumnName>).ColumnName = “Required Column Name”

Regards
Karteek YVN

Is this work if data table has more the one columns
@KarteekRPA

Yes… You need to use 1 assign activity for each column @jothyprasanth.m

@KarteekRPA
i have done this

Assign To:

Value:

Headers as column Values

I have an error in assign activity
Is this correct

Hi @jothyprasanth.m

Please refer the attached sample HeaderModification.xaml (7.8 KB)
You cannot run the above artifact, but you can use the logic

Regards
Karteek YVN

1 Like

Thank you @KarteekRPA

Got the Output

How to read the particular range

For example i have excel with Column A to Column AL i need to read only Column A to Column Z the rows are not in fixed number it will change every time.

How to do this

Hi @jothyprasanth.m

Use getRange Activity to find used range & get total number of rows
Then use read range, specify the column range as per your need & row count as you got from getRange activity

Regards
Karteek YVN

@KarteekRPA

Can you please tell how to do this

do u have any samples for that

Hi @jothyprasanth.m

You can refer these sample Check.xlsx (10.3 KB)
Excel ReadRange.xaml (6.4 KB)

Regards
Karteek YVN

1 Like

Thanks for your Response
@KarteekRPA

Read the Excel file Format

I have a source file,all the data’s are in the format of “Text”
I need to read all those data’s into destination file

I tried but the destination file format is general,so some of the column data’s are trim
How to do this ant idea

Can you send a sample excel file?

@jothyprasanth.m