Hi,
I have a sheet where I need to convert the values of some columns into decimal values upto 2 decimals.
the column names are:-
decimal1,decimal2,decimal3,deciaml4,decimal5,decimal6.
I have attached a sheet for the same.
Test2.xlsx (10.3 KB)
Can anyone let me know how to do it??
Use invoke code activity and pass this
dt.AsEnumerable().ToList().ForEach(
Sub(row)
row.SetField("decimal1", String.Format("{0:0.00}", Convert.ToDouble(row("decimal1").ToString)))
row.SetField("decimal2", String.Format("{0:0.00}", Convert.ToDouble(row("decimal2").ToString)))
row.SetField("decimal3", String.Format("{0:0.00}", Convert.ToDouble(row("decimal3").ToString)))
row.SetField("decimal4", String.Format("{0:0.00}", Convert.ToDouble(row("decimal4").ToString)))
row.SetField("decimal5", String.Format("{0:0.00}", Convert.ToDouble(row("decimal5").ToString)))
End Sub
)
Pass datatable variable with argument property
Hope this helps
Cheers @Kunal_Jain
Check this out
use write range activity to write it to an excel file
decimal.zip (3.1 KB)
hope this helps
If its clarified, would recommend to close this topic
Cheers @Kunal_Jain
Hi @Palaniyappan
It is giving me the error after attaching the data from the above provided excel
The error is:-
Invoke Code: Exception has been thrown by the target of an invocation.
Thanks in advance!!
Hi @Palaniyappan
Yes I have added an excel application scope and a read range activity.
And commented out the code of build data table.
Then I hope u have used the same datatable variable name
Run in debug mode to check what error has occurred
Yes I have used the same data table variable name and it is giving me the same error which I mentioned.
If you want I can share my updated workflow
decimal.zip (3.6 KB)
My excel is crashed so couldn’t include with excel that’s why I gave with datatable
To debug I can suggest in a way like
- Check with column names in the linq code
- Check with arguments whether u have passed the arguments correctly or not
- Run in debug mode and share the exception u r getting
Can u share the exception message a screenshot if possible and also ur invoke code screenshot
@Kunal_Jain
Hi @Kunal_Jain ,
Could you check by adding the Try Catch
blocks to the Invoke Code
Expression, it will help us to target the Error and get a clear Error message from it :
The Error message will be present in the Output Panel once it executes.
Hi @Palaniyappan and @supermanPunch
Thanks,
There was an empty column that we were sending.
The code is working but can we add an extra validation regarding empty column.
Cool
Hope it all clear now
Yeah you can add but that empty column cannot be added to the above code in INVOKE CODE activity as the above code tries to round of the value present in the highlighted column but your new column doesn’t have any value
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.