How to add decimal to price from datatable

How to add decimal to the price by finding the length of column value.

feks.
CurrentRow(1) has value = 5000 and I need to add 2 zero so that it shows 50.00.
another example,

CurrentRow(1) has value = 85000 and after adding zero it should be 850.00

I tried every thing… String.format, F2 and other but still no success.

@Ellen

Assign Activity:
Left side: newValue (String)
Right side: (Convert.ToDouble(CurrentRow(1).ToString)/100).ToString("F2")

Hi @Ellen

CurrentRow(0)= CurrentRow(0).ToString.Trim().Insert(CurrentRow(0).ToString.Trim.Length-2,".")

Regards

Hi @Ellen

→ Read the excel by using the Read range workbook activity and store it in a datatable.
→ Use for each row in datatable activity to iterate the rows in the datatable.
→ Inside for each insert the assign activity

- Assign -> Currentrow(1) = (Decimal.Parse(CurrentRow(1).ToString()) / 100).ToString(".00")

Check the below image for better understanding,

Input →
image

Output →
image

Hope it helps!!

Hi @Ellen

Try this

(From row In dt_Input.AsEnumerable() Select dt_Input.Clone().Rows.Add((CInt(CDec(row.Field(Of Double)("Amount")) / 100)).ToString("F2"))).CopyToDataTable()

image

Hope this helps!!

I have used:

CurrentRow(1).ToString.Insert(CurrentRow(1).ToString.Length-2,“.”)

Its working… Thanks for the help.

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