共计 2373 个字符,预计需要花费 6 分钟才能阅读完成。
SpreadJS 是一款基于 HTML5 的纯前端电子表格控件,兼容 450 种以上的 Excel 公式,凭借其“高性能、跨平台、与 Excel 高度兼容”的产品个性,备受以华为、苏宁易购、天弘基金等为代表的企业用户青眼。SpreadJS 为用户带来亲切的 Excel 应用体验的同时,满足 Web Excel 组件开发、表格文档协同编辑、数据填报、Excel 类报表设计等业务场景,极大升高了企业研发老本和我的项目交付危险。
点击下载 SpreadJS 最新试用版
应用 Date Occurring 规定
Date Occurring 规定是用来比对日期的。以下代码应用了 Date Occurring 规定。var style = new GC.Spread.Sheets.Style();
style.backColor = "red";
var rule = new GC.Spread.Sheets.ConditionalFormatting.NormalConditionRule(GC.Spread.Sheets.ConditionalFormatting.RuleType.DateOccurringRule, \[new GC.Spread.Sheets.Range(0,0,10,1)\], style, null, null, null, null, null, GC.Spread.Sheets.ConditionalFormatting.DateOccurringType.NextWeek);
activeSheet.conditionalFormats.addRule(rule);
var d = new Date();
activeSheet.setValue(0, 0, d);
activeSheet.setValue(1, 0, new Date(d.setDate(d.getDate()+1)));
activeSheet.setValue(2, 0, new Date(d.setDate(d.getDate()+5)));
activeSheet.setValue(3, 0,new Date(d.setDate(d.getDate()+6)));
activeSheet.setValue(4, 0,new Date(d.setDate(d.getDate()+7)));
activeSheet.setValue(5, 0, new Date(d.setDate(d.getDate()+8)));
// OR
var style = new GC.Spread.Sheets.Style();
style.backColor = "red";
activeSheet.conditionalFormats.addDateOccurringRule(GC.Spread.Sheets.ConditionalFormatting.DateOccurringType.NextWeek, style, \[new GC.Spread.Sheets.Range(0,0,10,1)\]);
var d = new Date();
activeSheet.setValue(0, 0, d);
activeSheet.setValue(1, 0, new Date(d.setDate(d.getDate()+1)));
activeSheet.setValue(2, 0, new Date(d.setDate(d.getDate()+5)));
activeSheet.setValue(3, 0,new Date(d.setDate(d.getDate()+6)));
activeSheet.setValue(4, 0,new Date(d.setDate(d.getDate()+7)));
activeSheet.setValue(5, 0, new Date(d.setDate(d.getDate()+8)));
应用 Duplicate 规定
Duplicate 规定用于查看单元格中反复的值。
示例代码
以下代码应用了 duplicate 规定。
var style = new GC.Spread.Sheets.Style();
style.backColor = "yellow";
var ranges=\[new GC.Spread.Sheets.Range(0,0,10,1)\];
activeSheet.conditionalFormats.addDuplicateRule(style, ranges);
activeSheet.setValue(0, 0, 50);
activeSheet.setValue(1, 0, 50);
activeSheet.setValue(2, 0, 11);
activeSheet.setValue(3, 0, 5);
// OR
var style = new GC.Spread.Sheets.Style();
style.backColor = "yellow";
var rule = new GC.Spread.Sheets.ConditionalFormatting.NormalConditionRule();
rule.ruleType(GC.Spread.Sheets.ConditionalFormatting.RuleType.DuplicateRule);
rule.ranges(\[new GC.Spread.Sheets.Range(0,0,10,1)\]);
rule.style(style);
activeSheet.conditionalFormats.addRule(rule);
activeSheet.setValue(0, 0, 50);
activeSheet.setValue(1, 0, 50);
activeSheet.setValue(2, 0, 11);
activeSheet.setValue(3, 0, 5);
本文转载自葡萄城
正文完