您好,您的这个需求,类似于Excel表格中条件格式的单元格色阶,Spread JS中可以实现,我贴一个JS的Demo给您参考:
- $(document).ready(function () {
- var spread = new GC.Spread.Sheets.Workbook(document.getElementById('ss'), {
- sheetCount: 1
- });
- initSpread(spread);
- });
- function initSpread(spread) {
- var activeSheet = spread.getSheet(0);
- activeSheet.suspendPaint();
- var scale = new GC.Spread.Sheets.ConditionalFormatting.ScaleRule();
- scale.ruleType(GC.Spread.Sheets.ConditionalFormatting.RuleType.threeScaleRule);
- scale.midColor("red");
- scale.midType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
- scale.midValue(50);
- scale.maxColor("blue");
- scale.maxType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
- scale.maxValue(100);
- scale.minColor("yellow");
- scale.minType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
- scale.minValue(10);
- scale.ranges([new GC.Spread.Sheets.Range(0, 0, 10, 10)]);
- activeSheet.conditionalFormats.addRule(scale);
- activeSheet.setValue(0,0, 10,3);
- activeSheet.setValue(1,0, 20,3);
- activeSheet.setValue(2,0, 30,3);
- activeSheet.setValue(3,0, 40,3);
- activeSheet.setValue(4,0, 50,3);
- activeSheet.setValue(5,0, 60,3);
- activeSheet.setValue(6,0, 70,3);
- activeSheet.setValue(7,0, 80,3);
- activeSheet.setValue(8,0, 90,3);
- activeSheet.setValue(9,0, 100,3);
- activeSheet.resumePaint();
- }
复制代码
|