您好,这种情况下,可以使用公式条件格式来实现,具体示例请参考下列代码:
- window.onload = function () {
- var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), { sheetCount: 2 });
- initSpread(spread);
- };
- function initSpread(spread) {
- var activeSheet = spread.getActiveSheet();
- // 创建Style,设置红色样式
- var style = new GC.Spread.Sheets.Style();
- style.backColor = "red";
- // 创建生效区域
- var ranges = [new GC.Spread.Sheets.Range(-1, 5, -1, 1)];
- // 设置条件格式
- activeSheet.conditionalFormats.addFormulaRule('=IF(F1<A1,TRUE,FALSE)', style, ranges);
- // 设置值:
- activeSheet.suspendPaint();
- for(let i=0; i<activeSheet.getRowCount(); i++){
- activeSheet.setValue(i, 0, activeSheet.getRowCount()-i);
- activeSheet.setValue(i, 5, i);
- }
- activeSheet.resumePaint();
- }
复制代码 |