I'm trying to fill a cell with "red" or "green" depending on its value; This is what I tried so far:
{{#xlsxAdd 'xl/worksheets/sheet1.xml' "worksheet.conditionalFormatting"}}
<conditionalFormatting sqref="G7:M7">
<cfRule type="cellIs" dxfId="0" priority="1" operator="notBetween">
<formula>{{productObj.min}}</formula>
<formula>{{productObj.max}}</formula>
</cfRule>
</conditionalFormatting>
{{/xlsxAdd}}
{{#xlsxAdd 'xl/worksheets/sheet1.xml' "worksheet.conditionalFormatting"}}
<conditionalFormatting sqref="G7:M7">
<cfRule type="cellIs" dxfId="2" priority="1" operator="between">
<formula>{{productObj.min}}</formula>
<formula>{{productObj.max}}</formula>
</cfRule>
</conditionalFormatting>
{{/xlsxAdd}}
but it seems that the condition notBetween
always matches the cell, but after I download the file then change the value of the cell, the conditions start to work correctly.
I don't know if reportjs is considering my numbers as strings
since changing the value after downloading the file works perfectly.
-- UPDATE ---
Found this issue: https://github.com/jsreport/jsreport-html-to-xlsx/issues/7
It was a problem with jsreport it's self for adding '
before my numbers which caused the conditional rendering to fail.
but still, I would appreciate a proper way to fill a cell "NOT" with the conditional formatting so I'll leave the question
--- END UPDATE ---
I also tried to fill with static color this but it didn't work:
{{#xlsxReplace "xl/styles.xml" "styleSheet.fills"}}
<fills count="5">
<fill>
<patternFill patternType="none"/>
</fill>
<fill>
<patternFill patternType="lightGray"/>
</fill>
<fill>
<patternFill patternType="solid">
<fgColor rgb="FFBFBFBF"/>
<bgColor rgb="FFBFBFBF"/>
</patternFill>
</fill>
<fill>
<patternFill patternType="solid">
<fgColor rgb="FFFF0000"/>
<bgColor rgb="FFFF0000"/>
</patternFill>
</fill>
<fill>
<patternFill patternType="solid">
<fgColor rgb="FF00FF00"/>
<bgColor rgb="FF00FF00"/>
</patternFill>
</fill>
</fills>
{{/xlsxReplace}}
// then adding the cell like this:
<c t="inlineStr" fillId="3" ><is><t>{{val}}</t></is></c>
but still not doing the job, I even tried to add dxfs
instead of fills
, if anyone can help me find out what am I doing wrong?!