这个是可以的,其实条件格式支持公式,公式可以直接拼接变量,参考下列代码:
- var spread = GC.Spread.Sheets.findControl("ss");
- var activeSheet = spread.getActiveSheet();
- var style = new GC.Spread.Sheets.Style();
- style.backColor = "red";
- var ranges = [new GC.Spread.Sheets.Range(0, 0, 2, 1)];
- var condition1 = 50;
- var condition2 = 60;
- activeSheet.conditionalFormats.addFormulaRule("="+condition1+"<"+condition2, style, ranges);
- activeSheet.setValue(0, 0, 2,3);
- activeSheet.setValue(0, 1, 1,3);
- activeSheet.setValue(0, 2,1,3);
- activeSheet.setValue(1, 0, 1,3);
复制代码 |