Hi Uipath,
I’m new to uipath and trying to solve one task.
Read the file Calculus.xlsx[Calculus.xlsx. Add a new column Result. If number 1 > number 2, subtract, else multiply them.
Expect a tax rate of 15%. Add another column that adds the tax rate to the result. This calculation should be done in the Windows calculator.
Save a new Excel-File with the results – the naming of the file follows this naming format: YYYY-MM-DD_Results.xlsx.
I had been done the process getting the error.
error: datatable collection is modified.
kindly let me know the solution for this.
Attaching my code and excel.
Main.xaml (16.9 KB)
Calculus.xlsx (9.0 KB)
Hi
Let’s go one by one
Use excel application scope and pass the file Path of calculus file as input and inside the scope use the read activity and get the output as dt
Now use a add data column activity to add a new column to the above datatable dt
personal_mail:
Add a new column Result
Then use a FOR EACH ROW activity and pass dt as input
Inside the loop use a IF activity with a condition like this
Convert.ToString(CurrentRow(“yourcolumnname”).ToString)>Convert.ToInt32(CurrentRow(“yourcolumnname”).ToString)
If it’s greater it goes to THEN block where use a assign activity to subtract the value using assign activity like this
CurrentRow(“Result”) = (Convert.ToInt32(CurrentRow(“yourcolumnname”).ToString) - Convert.ToInt32(CurrentRow(“yourcolumnname”).ToString)).ToString
If not it goes to ELSE block where multiple the value using Assign activity like this
CurrentRow(“Result”) = (Convert.ToInt32(CurrentRow(“yourcolumnname”).ToString) * Convert.ToInt32(CurrentRow(“yourcolumnname”).ToString)).ToString
Again same with add datacolumn to add new column for that tax rate and use some set of click activities to perform the calculation in windows calculator
Finally to save the file with the filepath we need, use a MOVE FILE activity and mention like this in the property panel
From or Source - mention the current FilePath
To or Destination - mention like this
Path.GetDirectory(“your current folder path to the file”)+”\”+Datetime.Now.ToString(“yyyy_MM_dd”)+”_Results”+”.xlsx”
Cheers @personal_mail
1 Like
system
(system)
Closed
October 29, 2021, 9:20am
3
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.