Format to a cell in excel

excel

#1

Hello every One!

I am looking for a solution to give formar to a cell in Excel, I want to change the Font depending on the text that I need to write.

Also, It will be great if you tell me how Can I change the size,type,color of the text?


How to change Excel cell font color
#2

Hi @Lucky0906,

In my case, I opened the excel file and handled all the formatting with Click Image, Send Hotkey and Type into activities in UIPath. So, I basically used those activities to activate Excel shortcuts in order to achieve what I wanted and I am afraid that UIPath doesn’t have specific activities for Excel cell formatting. Therefore, I suggest you give a try to this strategy.


#3

Thank you
Actually, I thougth of doing that you mentioned. However, I wanted to program all the activities directly in UIPATH and not to open Excel


#4

Hi @Lucky0906,

In this case, I suggest that you create a custom activity following the link below:


#5

Can you give a small example ?

I have small requirement such as if variable contains word ‘Error’, it should update cell with ‘Error’ Word but should be in bold letters.

For that, I have to write code first in C# and then call it in UiPath ?


#6

Hi @Chand,

In this case I would suggest you to do the following steps:

  • Read your excel file into a datatable (Read range activity)
  • Iterate in your excel file (For each row activity)
  • Check if your column contains this description (If activity)

#7

@Chand,

I would add to this my opinion.

Atleast until workbook application objects can be used directly to input and format cells, I use only Select Range and TypeInto for formatting with success. I don’t recommend Click and Send hotkey because they are inconsistent and only let you do one thing at once.

If you click Alt key in Excel it shows many letters. If you type a letter, you access all the different menu items.

For example,
TypeInto
"[k(alt)]horName[k(enter)]"

That will rename your sheet.

Or if you want text bold and colored:
TypeInto
"[k(alt)]h1[k(alt)]hfc[k(down)][k(right)][k(right)][k(right)][k(right)][k(enter)]"

Then, combine that with Select Range activity and you can select what you want to perform those actions on.

In order to get the range you want you can use .IndexOf to find the row number.
For Example, dt.Rows.IndexOf(row)
So you can do “A”+dt.Rows.IndexOf(row).ToString

You can also do this with Arrays with Array.IndexOf()

Therefore, if you only want to format certain cells

  1. Find Index of row you are on that you want to perform formatting, and possibly also the column index (so you can convert that to a character for column)
  2. Select Range
  3. Perform TypeInto keystroke combinations
  4. If needed, adjust Delay between characters

Modify a row from a Uipath datatable
#8

thanks, do you have an exercise done? What do you share? thank you