Convert column index to alphabetical characters UiPath
It is a very very rare scenario while designing a business process automation it is required to convert column index to alphabetical characters.
There is no direct activity in UiPath to convert this directly.
We will use logic to make it work for every scenario.
What are different scenarios?
- If the column index is less then or equal to 26 than it can also be converted to alphabets using Ascii values but when it comes to column index greater than 26 then it can’t be achieved using only Ascii values.
In this article, we will see how we can convert column index to alphabetical characters using UiPath.
Let’s jump into the practical implementation of this task:
Step1: Create a variable columnIndex of variable type integer. It is used as an input column index to further steps.
Step2: Drag and Drop an assign activity from the activities panel to the designer panel and create a variable (firstChar) of type Double and write the code as shown below:
Step3: Drag and Drop an assign activity from the activities panel to the designer panel and create a second variable (secondChar) of type Double and write the code as shown below:
Here we need to add one more condition before combining these two characters because when the columnIndex value is less than 26 it will give the wrong result.
Step4: Drag and Drop If condition from the activities panel to the designer panel as shown below:
It is checking whether the columnIndex value is less than or equal to 26.
Step5: Drag and Drop an assign activity from the activities panel to the designer panel in the Then section of If condition and create a variable (columnName) of type String and write the code as shown below:
The above code works when the columnIndex value is less than 26.
Step6: Drag and Drop an assign activity from the activities panel to the designer panel in the Else section of If condition and create a variable (columnName) of type String and write the code as shown below:
Step4: The output of the above sequence when the columnIndex is 53 is shown below:
Good to learn this informative logics.