How to build data table and write to excel when column header same name

Hi RPA developer,
I’m on learning Uipath and i need to know the right way. How to build data table and write to excel when column header same name and need specific data.
Sample I need report between 2021 and 2019

Year Year 2021 Year 2021 Year 2021 Year 2020 Year 2020 Year 2020 Year 2019 Year 2019 Year 2019 Year 2018 Year 2018 Year 2018
Month Up/Down Min Max Up/Down Min Max Up/Down Min Max Up/Down Min Max
ธ.ค. +1,350 25,550 27,050 20,900 21,650 +600 +300 17,950 18,450
พ.ย. -2,250 25,400 28,300 20,850 21,650 -50 -1,350 18,000 19,250
ต.ค. -500 27,650 28,600 21,250 21,800 +850 0 19,200 19,800
ก.ย. +200 27,750 28,100 -600 27,750 29,150 21,550 22,400 -450 +100 18,850 19,750
ส.ค. -550 27,400 28,450 -200 27,500 30,400 20,550 22,400 -550 +1,150 18,100 19,650
ก.ค. +1,600 26,850 28,400 +3,150 26,000 29,300 20,050 21,000 -350 -750 17,900 18,800
มิ.ย. -1,450 26,400 28,200 -150 25,200 26,200 19,500 20,750 -100 -200 18,800 19,150
พ.ค. +2,050 26,150 28,200 -150 25,800 26,600 19,250 19,450 +50 +200 18,550 19,500
เม.ย. +1,100 25,300 26,600 +1,250 24,650 26,400 19,250 19,650 0 +600 18,250 18,800
มี.ค. -100 24,450 25,600 +1,200 22,600 25,250 19,400 19,800 0 -450 17,950 18,750
ก.พ. -1,100 25,100 26,450 +500 22,750 25,300 19,350 19,800 -250 -1,250 18,450 19,850
ม.ค. -650 26,050 27,650 +1,700 21,450 23,350 19,250 19,700 -150 +1,350 18,550 20,150
สรุป +1,100 24,450 28,450 +5,300 21,450 30,400 19,250 22,400 -400 -300 17,900 20,150
Expected
Month Month/Condition Year 2021 Year 2020 Year 2019
ธ.ค. Up/Down +1,350 20,900
พ.ย. Up/Down -2,250 20,850
ต.ค. Up/Down -500 21,250
ก.ย. Up/Down +200 -600 21,550
ส.ค. Up/Down -550 -200 20,550
ก.ค. Up/Down +1,600 +3,150 20,050
มิ.ย. Up/Down -1,450 -150 19,500
พ.ค. Up/Down +2,050 -150 19,250
เม.ย. Up/Down +1,100 +1,250 19,250
มี.ค. Up/Down -100 +1,200 19,400
ก.พ. Up/Down -1,100 +500 19,350
ม.ค. Up/Down -650 +1,700 19,250
สรุป Up/Down +1,100 +5,300 19,250
[Sample.xlsx attachment](upload://62PRT1hTT7yNkPK0OJ4EUteFQ9j.xlsx) (10.1 KB)

Thank you so much.

@HLerm

Welcome to the forums

Use Read Range and Remove checkbox of Add Headers from properties
Now use Filter Datatable and go to columns and give columns as Index

Hope this may help you

Thanks

Hi

Welcome to uipath community

Hope these steps would help you resolve this

—use a excel application scope and pass the filepath of the excel and inside the scope use a read range activity and get the output as dt and in read range property disable ADD HEADERS property so that you will get the column names as Column-1, Column-2…… for your datatable

—now if you want to get specific columns provided you know the column index or the name say for example I need column 1,3 and 5
Then use this expression in a Assign activity like this

dt = dt.DefaultView.ToTable(False,”Column-1”,”Column-3”,”Column-5”)

This dt now will only the mentioned columns in it

Or if you want to filter based row data click hen use a FILTER DATATABLE ACTIVITY and mention the condition you want and get the output datatable

Cheers @HLerm

Hi @Srini84 Thank you for advise. I will try it.

Hi @Palaniyappan
Thank you for advise. I will try and update to you. :pray:

1 Like