How to convert String (like $12,554.10) to integer and add as data row

my string is captured as per title, but I cannot use integer.parse (String) in the data row.

How do I get it to recognize the correct amount and pasted in Excel correctly as a currency?

For now, the numbers are “pasted as text” and I am unable to sum them unless I convert them in Excel - not ideal.

@auto Use string replace method to replace “$”(if your required replace “,”) with null value(“”).

it still gets stored as TEXT in Excel. Able to share a sample script please?

Hi Greetings!

InputString.Replace(“$”,“”).Replace(“,”,“”)

This will return only number. Then u can use it in add data row.

Thanks!

@auto You wanted to sum the values in excel or you can sum the values in datatable also?

@auto

You need to first replace the “$” & “,” with “”(Empty string). then convert the variable to Double type.

Convert.ToDouble(“RetrievedVariable”.Replace(“$”,“”).Replace(“,”,“”))

or
You can do it using the other method of Interger.Parse(“RetrievedVariable”.Replace(“$”,“”).Replace(“,”,“”))

Hope it works!!

Cheers buddy.

Hi @auto

The comments by others are quite enough for you to figure out a way to remove the characters and convert it to double.

Your other concern, sum them up, Yes. You can sum the records within a datatable itself. The code is kind of lengthy. But you can easily use the below component to get it done.

Install it and use the consolidate data table activity to get the aggregated datatable according to your requirement.

https://go.uipath.com/component/datatable-plugins

Hope it helps

1 Like

Hi guys,

I am still getting the error shown below. Appreciate if someone can post a sample script so that I can take reference from there. Thank you!