Append columns when columns headers are random

Hi…I have 2 excel workbooks(first excel workbook=template1 & second workbook=template2).
in template1 two sheets are der and in that columns are der like
in sheet 1
Sheet Name Age Address study
1 Charan 30 bangalore degree
1 ravi 25 hyd b-tech
AND IN SHEET 2
Sheet Name Age Address study
2 KIRAN 40 DELHI PG
2 KUMAR 50 MUMBAI PHD

i have to read them and copy them put them into template2 workbook in sheet 1…but columns are very ramdom like

Sheet Address study Name Age
1 bangalore degree Charan 30
1 hyd b-tech ravi 25
2 DELHI PG KIRAN 40
2 MUMBAI PHD KUMAR 50

shud append them like this can anyone please help me with this

Hello,

I think you can rearrange columns in excel and then use the append activity.

If not try using is statemment to check if the headers match and then use append activity.

Thank you
Anusha

@ryava_santhoshi

Before using Write Range activity try the below expression in Assign statement.

your_appended_datatable = your_appended_datatable.DefaultView.Totable(false,"Street","Name","Age","Address","Study")
2 Likes

if you donot mind can you please provide my xaml of it

@ryava_santhoshi

can you share your xaml. I can edit your file and share.

1 Like

ExportedData.xlsx (11.1 KB)
test.xlsx (8.7 KB)

for understanding purpose i provided two excel work books…from export excel data shud be pasted in test excel as per its column headers and shud be appended and amount shud be higher to lower please try to help me with this

@ryava_santhoshi, here is your solution. Please find the attached workflow. AppendColumns.zip (23.2 KB)

Please make sure you have the same column name in all the sheet. However, you can have the order of the column in any manner you want. Please let me if i have resolved your issue

1 Like

thank you so much @ Hashim_Shamsudeen…this is really helpful…but wt if i have more than 2 sheets like around 10 sheets how to merge them

You are welcome @ ryava_santhoshi . You can use a array of sheet names and loop through the array. Basically. Define a main data table with exact table schema as your sheet tables . Read the sheet 1 and merge to the main dt. And repeat the process until all the sheet names are read in the array of sheet.

If you check InitAllSettings in RE Frame work you could see a similar approach for reading data from the sheet. But the only difference is der they are adding the data to a dictionary. So you could adopt the same approach by just changing it to a merge data table . Hope you are clear with my explanation?

1 Like

@ryava_santhoshi

Refer this xaml for appending multiple sheets

sample.xaml (13.7 KB)

1 Like

thank you so much ranjith

1 Like

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