Copy the row items into Datatables


#1

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)


#2

Can you check below (not sure about result)

Read Range Dt (without Addheaders checked)

NewDt= Dt.Copy()

Write Range NewDt (with AddHeaders checked)


#3

Hi @jothyprasanth.m

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

Regards
Karteek YVN


#4

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

you can go with @KarteekRPA 's solution.


#5

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).


#6

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


#7

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


#8

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


#9

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


#10

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


#11

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


#12

@KarteekRPA
i have done this

Assign To:

Value:

Headers as column Values

I have an error in assign activity
Is this correct


#13

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


#14

Thank you @KarteekRPA

Got the Output


#15

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


#16

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


#17

@KarteekRPA

Can you please tell how to do this

do u have any samples for that


#18

Hi @jothyprasanth.m

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

Regards
Karteek YVN


#19

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


#20

Can you send a sample excel file?

@jothyprasanth.m