How change the format in excel?

Hi Team,

I got a use case that after extracting the data table from the website I need to change the format the format looks like below.

Column name: Balance
(1234.23)
(34524.56)

Here I need to do the format like
Balance
-1234.23
-34524.56

How to do the format in UiPath Can anyone help me?

Thanks,
Chethan P

@copy_writes

Please use format cells activity from excel activities which hs an option to set the format and you can set as number

Cheers

Yes, we can do that in the extraction data part we have a setting to convert to numbers but I need “-1234.23” subtraction symbol is needed.

@copy_writes

Ideally number would convert the bracket values to minus in the excel

if not you can use custom and give this format #,##0.00_ ;-#,##0.00

cheers

Can you please explain how to use this I am not getting

Hi @copy_writes

  1. Use the Read Range activity to extract the data table from the website and store it in a variable, let’s say dtData.
  2. Add a ForEach Row activity and set the Input property to dtData.
  3. Inside the loop, add an Assign activity to modify the format of the “Balance” column.

Assign activity:
Left side: row(“Balance”)
Right side: “-” & Math.Abs(Double.Parse(row(“Balance”).ToString())).ToString(“#0.00”)

The above expression converts the value of the “Balance” column to a Double, takes the absolute value, adds a “-” sign, and formats it with two decimal places.
4. After the ForEach Row activity, you can use the modified DataTable dtData, which now has the “Balance” column values in the desired format.

Hope it helps!!

I am getting an error when I am run this code.

Try this

  1. Read Range

    • Input: Website Data Table Range
    • Output: dtData (DataTable)
  2. For Each Row

    • Input: dtData
    1. Assign
      Left side: row(“Balance”)
      Right side: “-” + Math.Abs(Convert.ToDecimal(row(“Balance”)))
  3. Write Range

    • Input: Destination Excel File Path
    • Input: dtData

I Am getting an error

can you share sample input file? it will be better

Give a try
By Storing the row(“Balance”).tostring in the variable and pass here in the to: of assign

@copy_writes

This is how you can do it

image

cheers

What is the range we have to give in the Source field?

@copy_writes

If you want one full column to be changed then Excel.Sheet("Sheetname").Range("H:H") this for whole H column

cheers

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