Skip to content

Get Excel Cell Color Function: getCellColor

The   function retrieves the background color of a specified cell in an Excel sheet. The extracted color value is stored in a variable for further use in automation workflows.

Note: Ensure that the file being used is not open during the execution of the Case to avoid errors or conflicts.

Example: You have an Excel file named EmployeeData.xlsx stored at C:\Data. You want to get the background color of cell E2 in the SalarySheet and store it in a variable.

Steps to Configure:

  1. Add a new step.
  2. Select Set a Variable Value from the Action dropdown.
  3. Enter a variable name in Element Key (e.g., CellColor). This variable will store the extracted color.
  4. Click on Form, select Functions, and choose Get Excel Cell Color.
  5. Provide the following parameters:
    • FPath: Specify the full path of the Excel file (e.g., C:\Data\EmployeeData.xlsx).
    • CellReference: Enter the cell reference (e.g., E2).
    • SheetName: Specify the sheet name (e.g., SalarySheet).
    • SheetNumber: Enter the sheet number (e.g., 1 for the first sheet).
    • ColorFormat: Choose how the color should be returned (options: RGB, ARGB, Hex, Name).
  6. Click Save.

Note: While the steps for adding an Action are identical in both views, the display of the steps changes:

scrn-get-cell-color-tabular-view
Tabular View
scrn-get-cell-color-card-view
Card View

Outcome on Execution:

  • The color of the specified cell is extracted and stored in the variable CellColor. For example, if cell E2 has a background color of sky blue, the variable CellColor might store:
    • RGB: (135, 206, 235)
    • Hex: #87CEEB
    • Name: Sky Blue
  • You can use this variable in automation using the syntax ${CellColor}.

Back To Top