Copy column data from one excel file to another but different column name

Hiii, I’m new to UiPath studio, we use Community Edition 2023.4
I want to Create a new Excel file using old Excel file data,I mean copy the selected columns from one Excel to another but with a different column name.
Example-code is a column name in an old excel file, copy code data and create a new excel file and save it with the name Emp Code.
How can design a job for the above or which activity use?

Hi @ashwini.mali

Do you want to change the headers in new excel file?

yes @vrdabberu

Hi @ashwini.mali

Declare a new data table newDt & load the required columns to it from the old data table like this:

newDt = oldDt.DefaultView.ToTable(False,"Col1","Col2","Col3",......)

Then you can change the column names like this:

yourDt.Columns("Old Column Name").ColumnName = "New Column Name"

Hope this helps,
Best Regards.

Which Activity use for above ,how
Assign Activity? @vrdabberu @arjunshenoy


You can do it like this:

This is my source data table, I only want ‘OldCol1’ data to be loaded to the new data table.


This is how it’s done:

In the above workflow, I am only loading ‘OldCol1’ data to the new data table & then changing it’s name.

Hope this helps,
Best Regards.

okay @ashwini.mali

Read entire data of old excel file using read range activity and mark as add headers to true in properties panel.

Use build data table and create the columns of required names but in the same order as previous excel.

use filter data table and based on your requirements filter the data.
input data table: “Stored data table variable” Filtered data table : “New data table variable”
There is an option like Output columns so mentions all the required columns you wanted in that but mention the columns names within the double quotations.
At last use the write range work book activity and do not mark the add headers to true in properties panel.

Hope it works !!


Thank you so much for reply and solution ,issue resolved @arjunshenoy @vrdabberu

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.