'R - Unable to select color using bgFill under createStyle command in openxlsx package
I am unable to select the color for the spreadsheet cells using the option bgFill.
wb <- loadWorkbook("workbook.xlsx")
s <- createStyle(bgFill = "#FFC7CE")
addStyle(wb,sheet = 1, s, cols=1:100, rows=1:100,gridExpand = TRUE)
Although I change the hex code on bgFill, my cells remain black in colour on the spreadsheet. I have tried predefined colours like red, green and blue too. I am unable to switch the colour of cells.
Solution 1:[1]
For people who, years after, might encounter this problem like me...
As @IceCreamToucan states, you should use fgFill instead of bgFill which is for conditional formatting. Openxlsx documentation writes for the createStyle function (link):
bgFill:
Cell background fill colour. A valid colour (belonging to colours()) or a valid hex colour beginning with "#". – Use for conditional formatting styles only.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | DjibSA |
