I am using exceljs to create an excel workbook. A sheet will have a range of A1:AR106. My data objects will contain 3 properties (numtype, nummax, nummin). Only properties nummax and nummin will appear on the sheet. I can successfully create the workbook with formatting but I am not able to make conditional formatting of individual cells work.
I would like to color cells depending on the value of numtype. For example, if numtype = 'abc', the nummin cell will be lightblue and nummax will be lightred. So i would expand this for other possible values of numtype and set colors for nummin/nummax accordingly.
I found documentation for exceljs at https://github.com/exceljs/exceljs#conditional-formatting but I have not been able to make conditional formatting of cells work for me.
worksheet.addConditionalFormatting({
ref: 'A3:AR106',
rules: [
{
type: 'containsText',
operator: 'containsText',
text: 'abc',
style: {fill: {type: 'pattern', pattern: 'solid', bgColor: {argb: '#98b8eb'}}},
}
]
})
Does anyone have an example I could follow that would lend itself to what I have described?
Thanks Dan