Add decimal value into price

I want to create a bot which find the format of price from excel and then give result according to that.

like:
amount in excel is = 10000 the result should be 10.000,00
OR
amount in excel is = 10.000 the result should be 10.000,00
OR
amount in excel is = 10.000,00 then it shoud stay as it is 10.000,00

how can i do it?

Hi @Latif

Use this below Invoke code:

For Each row As DataRow In dt.Rows

    Dim raw As String = row(0).ToString().Trim()

    ' Remove all symbols except digits, . , and -
    raw = Regex.Replace(raw, "[^\d\.,\-]", "")

    ' Convert:
    ' If comma exists → treat as decimal separator
    ' Else → treat as integer without thousands separators
    Dim normalized As String =
        If(raw.Contains(","c),
            raw.Replace(".", "").Replace(",", "."),
            raw.Replace(".", "")
        )

    ' Parse using invariant culture
    Dim numberValue As Decimal =
        Decimal.Parse(normalized, System.Globalization.CultureInfo.InvariantCulture)

    ' Convert to European (de-DE) format → 10.000,00
    row(0) = numberValue.ToString("N2", System.Globalization.CultureInfo.GetCultureInfo("de-DE"))

Next

Invoke Code Arguments:

Hope it helps!!
Parvathy

I need UiPath method not code.

Invoke Code is an activity which can be used within UiPath @Latif

Regards
PS Parvathy

Use this activity-wise flow :—

  1. Use Excel File
    Open your Excel file.

  2. Read Range
    Read the sheet into a DataTable, for example ‘dtData’.

  3. For Each Row in Data Table
    Loop through each row.

  4. Assign
    Inside the loop:
    inputText = row(“Amount”).ToString.Trim

  5. If
    Condition:
    Not String.IsNullOrWhiteSpace(inputText)

Inside Then:

  1. Assign
    normalizedText = inputText.Replace(“.”, “”).Replace(“,”, “.”)

  2. Assign
    amountValue = Convert.ToDecimal(normalizedText, System.Globalization.CultureInfo.InvariantCulture)

  3. Assign
    resultText = amountValue.ToString(“#,##0.00”, New System.Globalization.CultureInfo(“de-DE”))

  4. Assign
    If you want to update the same datatable column:
    row(“Amount”) = resultText

After loop ends:

  1. Write Range
    Write ‘dtData’ back to Excel.

Variables to create

dtData → DataTable
inputText→ String
normalizedText→ String
amountValue → Decimal
resultText → String

Happy Automating !

Regards,
Dhruba

Hi Latif

Another version of what Latif is writing you can find here: GitHub - AutomationGems/UiPath-Forum-Examples: Examples used for UiPath answers · GitHub and the project is called ‘Add Decimal value into price’

I takes the following formats:

And converts to this:

What it does is to check if there is a comma and if yes then check if the is before or after the dot. This way it finds out if it is in us format or european format.

I tried this solution.. it worked fine when my Excel Format of column is Text then its give me right answer.


Then i get answer as.
image

But when my Excel column is in Brugerdefineret.. it give wrong answer

It return Just 14,00.
image

So one part i working but not other.

Hi

I don’t know if you tried the solution I proposed? But for the other solution you tried, you can try to check of the ‘Use Display Format’ property

image

The reason it return 14,00 is that in english number format the ‘.’ (dot) is NOT a thousands separator. So it thinks that after the dot is decimals.

This is the flow from the project I linked to: