我正在使用exceljs创建一个excel工作簿。一张图纸的范围是A1:AR106。我的数据对象将包含3个属性(numtype、nummax、nummin)。只有属性nummax和nummin将显示在工作表上。我可以成功地创建具有格式的工作簿,但我无法使单个单元格的条件格式生效。
我想根据numtype的值给单元格上色。例如,如果numtype = 'abc',那么nummin单元格将为lightblue,nummax将为lightred。因此,我将对numtype的其他可能值进行扩展,并相应地为nummin/nummax设置颜色。
我在https://github.com/exceljs/exceljs#conditional-formatting上找到了exceljs的文档,但我还不能使单元格的条件格式为我所用。
worksheet.addConditionalFormatting({
ref: 'A3:AR106',
rules: [
{
type: 'containsText',
operator: 'containsText',
text: 'abc',
style: {fill: {type: 'pattern', pattern: 'solid', bgColor: {argb: '#98b8eb'}}},
}
]
})有没有人有一个我可以效仿的例子,来证明我所描述的?
谢谢,丹
发布于 2021-03-19 06:17:02
我在https://www.freakyjolly.com/create-excel-from-json-in-angular-98-using-exceljs-tutorial-with-example/#.YFPFM2RKiqA的“有条件地格式化单元格”小标题下找到了一个合理的解决方案来满足我的需求。
我认为它也可以针对其他条件格式需求进行定制。对我来说效果很好。
https://stackoverflow.com/questions/66692875
复制相似问题