Set-Area-Font-Color
Command Description
Set the font color of the specified cell. The attribute is in the form of array form, such as [R, G, B]
Command Prototype
Excel.SetRangeFontColor(objExcelWorkBook,sheet,strRange,listColor,bSave)
Parameter Description
Parameter | Required | Type | Default | Description |
---|---|---|---|---|
objExcelWorkBook | True | expression | objExcelWorkBook | Excel workbook object (workbook opened with "Open Excel" command (Excel.OpenExcel) or the workbook object returned by the command "Bind Excel" (Excel.BindBook)) |
sheet | True | string | "Sheet1" | The string means sheet name. The number means sheet order(starting from 0) |
strRange | True | string | "A1:B2" | The specified cell, supports two forms: cell names (such as "A1:B2") or two-dimensional array of rows and columns (such as [[cell1 Row number, cell1 column number],[cell2 Row number, cell2 column number]]). When using cell names, it is case insensitive |
listColor | True | expression | [255,255,255] | Color in RGB array format |
bSave | True | boolean | None | Save immediately after the operation |
Demo
/************************Set area font color********************** *********
**Input 1:
** objExcelWorkBook--Excel workbook object (a workbook opened using the "Open Excel" command (Excel.OpenExcel) or a job bound using the "Bind Excel" command (Excel.BindBook) book object).
**Entry 2:
** sheet--If a string is used, it means the name of the specified worksheet; if a number is used, it means the order of the specified worksheet (starting from 0).
**Entry 3:
** strRange--Specified range, supports cell names such as "A1:B2" and two-dimensional row and column arrays such as [[cell 1 row number, cell 1 column number], [cell 2 Row number, cell 2 column number]] two forms, case-insensitive when using cell names.
**Entry 4:
** listColor-- RGB colors in array form.
**Entry 5:
** bSave--The operation is completed and saved immediately. (boolean true/false)
**
*********************************************************************/
objExcelWorkBook = Excel.OpenExcel(@res"Test.xlsx",True,"Excel","","")
Excel.SetRangeFontColor(objExcelWorkBook,"Sheet1","A3:B5",[255,0,0],False)
TracePrint "Set area font color: The area font where Excel object Sheet1'A3:B5' is located is set to red"
Excel.CloseExcel(objExcelWorkBook,True)