How to add 2 decimal at end of column number

Hello all
I have Excel sheet with Column name Bill_Amount
Values are
Bill_Amount
2500
13566.90
6000
0.31

I want to convert into

Bill_Amount
2500.00
13566.90
6000.00
0.31

Please help me to resolve this isy

Hi @Rohan_Dhole

Asuming that all are number values you can perform the following

CDbl(CurrentRow("ColumnName").ToString).ToString("#.00")

Regards

Hi @Rohan_Dhole
Can you try
Decimal.Parse(yourString).ToString(“###.####.####.##”)
Regards,
LNV

@Rohan_Dhole

  1. Excel Application Scope (provide the file path)
    2. Read Range (output: dtData)
    3. For Each Row (input: dtData)
    4. Assign - row(“Bill_Amount”) = Decimal.Parse(row(“Bill_Amount”).ToString).ToString(“0.00”)
    5. Write Range (input: dtData, provide the starting cell)

Hey @Rohan_Dhole
Below is the input and output screenshot
Input screenshot
image

Output sreenshot
image

So i achieved this using string.format method
Below is the code
String.Format("{0:0.00}", Convert.ToDouble(CurrentRow("Bill_Amount")))

Below is the file for your reference
Testt.zip (10.6 KB)

Hope it helps you!

Hello Sir! I Tried This solution but Did not work !

Hello sir! This also not worked!

Hi, You can try format cells
image

  1. Read Range

    • Input: Path to the Excel file
    • Output: dataTable (DataTable variable)
  2. For Each Row (row) in dataTable

    • Values: dataTable
    1. Assign
      • To: currentRow(“Bill_Amount”)
      • Value: Convert.ToDecimal(currentRow(“Bill_Amount”)).ToString(“N2”)
  3. Write Range

    • Input: Path to the Excel file
    • DataTable: dataTable

Follow this steps to get the required output! Hope it helps

Regards!

Convert.ToDecimal(currentRow(“Bill_Amount”)).ToString(“N2”)

For this I have used Invoke VBA Activity

I have written VBA code in text format.

Sheets(“Sheet1”).Range(“E:E”).NumberFormat = “0.00”
Using this I have changed format of column

1 Like

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