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
- 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)
- Select Range
- Perform TypeInto keystroke combinations
- If needed, adjust Delay between characters