【发布时间】:2020-06-10 21:02:04
【问题描述】:
我正在尝试用 "red" 或 "green" 填充单元格,具体取决于其值;这是我迄今为止尝试过的:
{{#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}}
但似乎条件notBetween总是匹配单元格,但是在我下载文件然后更改单元格的值后,条件开始正常工作。
我不知道 reportjs 是否将我的数字视为 strings,因为在下载文件后更改值效果很好。
-- 更新 ---
发现这个问题:https://github.com/jsreport/jsreport-html-to-xlsx/issues/7
这是 jsreport 的问题,它自己在我的数字前添加 ' 导致条件渲染失败。
但是,我仍然希望有一种用条件格式填充单元格“NOT”的正确方法,所以我会留下问题
--- 结束更新 ---
我也尝试用静态颜色填充这个,但是没有用:
{{#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>
但仍然没有做这项工作,我什至尝试添加dxfs而不是fills,如果有人可以帮助我找出我做错了什么?!
【问题讨论】:
标签: handlebars.js xlsx jsreport