セルに条件付き書式を設定できます。
次のサンプルコードは、条件付き書式を設定します。
JavaScript |
コードのコピー
|
---|---|
window.onload = function(){ var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"),{sheetCount:3}); var activeSheet = spread.getActiveSheet(); //それぞれの条件付きスタイルを作成します。 var styleBlue = new GC.Spread.Sheets.Style(); var stylePink = new GC.Spread.Sheets.Style(); var styleLime = new GC.Spread.Sheets.Style(); var styleYellow = new GC.Spread.Sheets.Style(); var styleEmpty = new GC.Spread.Sheets.Style(); styleBlue.backColor = "blue"; styleBlue.foreColor = "white"; stylePink.backColor = "pink"; styleLime.backColor = "lime"; styleYellow.backColor = "yellow"; styleEmpty.backColor = undefined; styleEmpty.foreColor = undefined; //それぞれのセルに条件付き書式を設定します。 activeSheet.conditionalFormats.addCellValueRule( GC.Spread.Sheets.ConditionalFormatting.ComparisonOperators.EqualsTo, 0, undefined, styleEmpty, [new GC.Spread.Sheets.Range(1, 1, 1, 1)]); activeSheet.conditionalFormats.addCellValueRule( GC.Spread.Sheets.ConditionalFormatting.ComparisonOperators.LessThan, 10, undefined, styleBlue, [new GC.Spread.Sheets.Range(1, 1, 1, 1)]); activeSheet.conditionalFormats.addCellValueRule( GC.Spread.Sheets.ConditionalFormatting.ComparisonOperators.Between, 20, 50, stylePink, [new GC.Spread.Sheets.Range(2, 1, 1, 1)]); activeSheet.conditionalFormats.addCellValueRule( GC.Spread.Sheets.ConditionalFormatting.ComparisonOperators.Between, 50, 80, styleLime, [new GC.Spread.Sheets.Range(3, 1, 1, 1)]); activeSheet.conditionalFormats.addCellValueRule( GC.Spread.Sheets.ConditionalFormatting.ComparisonOperators.GreaterThan, 80, undefined, styleYellow, [new GC.Spread.Sheets.Range(4, 1, 1, 1)]); activeSheet.getCell(2, 1).value(25); activeSheet.getCell(3, 1).value(77); activeSheet.getCell(4, 1).value(88); } |