SpreadJS製品ヘルプ
日付ルール
機能 > 条件付き書式 > 日付ルール

日付ルールは、複数の日付を比較します。

コードの使用

次のサンプルコードは、日付ルールを作成します。

JavaScript
コードのコピー
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)));
 // または
 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)));
関連トピック