Could not able to make column value into two decimal

Hi all,

I have attached the xlsx file. in D column I have amount data which is string. I would like to make all the data upto two decimal.

I have applied - String.Format(“{0:0.00}”, row(“Amount”).ToString) but it is not working. as it is a string column I could not able to use convert.todouble also.

Please share your feed back with me how I going to make it two decimal value for each row of amount column.
data.xlsx (9.0 KB)

Thanks in advance.

Hi @roysupriya21

Try this:
=> Use Read Range Workbook to read the excel and store the outpu in datatable say dt_data
=> Use For Each Row in DataTable to iterate through dt_data
=> Use below syntax in Assign acitivty.

CurrentRow("Amount")= Decimal.Parse(CurrentRow("Amount").ToString)

=> Use Write Range Workbook to write it back into same sheet or different sheet.

Hope it helps!!

Hi @roysupriya21

  1. Read Range: Use the Read Range activity to read the data into a DataTable variable.
  2. For Each Row in DataTable: Iterate through each row of the DataTable.
  3. Assign Activity Inside the Loop:

If Double.TryParse(row(“Amount”).ToString, tempAmount)
Then
row(“Amount”) = tempAmount.ToString(“F2”)
Else
’ Handle the case where the conversion fails, perhaps set to “0.00” or leave as is
row(“Amount”) = “0.00”

I am getting error.

image
it is a string data type column. so I guess I can not make it system.decimal

Hi @roysupriya21
Assign the syntax in the same way. It won’t throw any error. If possible share your excel file.

CurrentRow("Amount")= Decimal.Parse(CurrentRow("Amount").ToString)

Hope it helps!!

@roysupriya21

Just add a .ToString at the end on right side in you assign activity

Aso you want to change the display in excel? If so use format cells activity instead

Cheers

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