Read Two Specified Column from Excel and Store the calculated value in another excel

Hi All,

I’m new to UiPath. Is there any example steps to show how should I read the data from specified column and calculated it, then display it as column in another excel?

For example. I have an excel file with 4 columns.
image

I wanted to read the data from column ShippingFees and Tax Amount. After retrieved, I want to do a calculation, save it in another excel. How can I achieve that?

Thank you.

Hi @Gwen

Please find the attached workflow try it and let me know if you face any issues
ReadFromOneExcelandStoretoOther.xaml (9.9 KB)

Step1: Use ReadRange activity to read your excel into Datatable.
Step2: Use build data table activity to build the datatable with required columns.
Step3: Use For each row as datatable and pass your datatable activity.
Step4: Inside for each use assign activity and assign the required values to a variable as
VariableName(Left) = Row(“YourColumnName”)
Step5 : Use Add data row activity
Step6: At last you can use write range activity to write the data to the new excel.

Or

You can do it by using linq as well if you want let me know I will post that solution as well

Thanks

2 Likes

Hi

Welcome to uipath community

Hope the below steps would help you resolve this

—read the excel with excel application scope and pass the file path as input and get the output with a variable of type datatable named dt
—then use a assign activity like this

finaldt = dt.DefaultView.ToTable(False,”Shipping Fee”,”Tax Amount”)

FinalDt is a datatable variable defined in Variable panel with default value as
New system.Data.Datatable

Now Finaldt will have only the two columns which you can iterate now with FOR EACH ROW ACTIVITY and perform calculation and move it to another excel with write range activity

Cheers @vinithareddyk123

2 Likes

Hi @Gwen

Did this work?

Hi @vinithareddyk123 ,

Yes, it works! Thanks for the detailed steps solution and explanation!

Thanks.

1 Like

Hi @Palaniyappan

Thanks for the solution, it works for me too!
But I have one question on this
finaldt = dt.DefaultView.ToTable(False,”Shipping Fee”,”Tax Amount”)
Is this similar to Build Data Table?

Thanks.

Ah not exactly
It’s used to get the specific columns with distinct values if needed

@Gwen

1 Like

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