How to formate excel cell using ui path

I have to formate excel cell in 3 digit. e.g if 1 is written it become 001 if 23 in cell it become 023.
Hiw we achieve this using ui path… Please help me how to do this

Hi @rakhi1

You can use Pad Left string operation

assign a variable str_Input = “1”

str_Input.PadLeft(3,"0"c) - You can check in message box =>Output = 001

if you give str_Input 23 = output is 023
if str_Input 223 then it will display as it is i.e 223



Try below steps.

  1. Use Read Range activity to read the data from the Excel file and it will give output as DataTable. Let’s say InputDT.

  2. Let’s say you want to add leading zeros in first column values.

    For Each row in InputDT
        row(0) = row(0).ToString.PadLeft(3,Cchar("0"))

Here, 0 refers to first column. Change it according to your column position in the input file.

  1. Finally use Write Range activity and pass InputDT to write back into Excel file.

Thank u @Boopathi.M and @lakshman I definately try both methods… thanks for your help it help me a lot

i tried this method it fill “o” in place of blank cell

I solve this problem using invoke vba… thanks

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