MESCIUS SPREAD for Windows Forms 17.0J サンプルコード集 > 操作 > セル > 条件付きフォーマット(データバー、カラースケール、アイコンセット)を設定する |
データバー、カラースケール、アイコンセットの実装は、通常の条件付フォーマットのものと基本的には同一ですが、条件を設定する定義するオブジェクトが異なります。データバー、カラースケール、アイコンセットはそれぞれDatabarConditionalFormattingRuleオブジェクト、TwoColorScaleConditionalFormattingRuleオブジェクト、IconSetConditionalFormattingRuleオブジェクトを使用します。
private void Form1_Load(object sender, EventArgs e) { // データの設定 fpSpread1.ActiveSheet.Columns[0].Label = "データバー"; fpSpread1.ActiveSheet.Columns[0].Width = 100; fpSpread1.ActiveSheet.SetValue(0, 0, 10); fpSpread1.ActiveSheet.SetValue(1, 0, 20); fpSpread1.ActiveSheet.SetValue(2, 0, 30); fpSpread1.ActiveSheet.SetValue(3, 0, 40); fpSpread1.ActiveSheet.SetValue(4, 0, 50); fpSpread1.ActiveSheet.SetValue(5, 0, 60); fpSpread1.ActiveSheet.SetValue(6, 0, 70); fpSpread1.ActiveSheet.SetValue(7, 0, 80); fpSpread1.ActiveSheet.Columns[1].Label = "カラースケール"; fpSpread1.ActiveSheet.Columns[1].Width = 100; fpSpread1.ActiveSheet.SetValue(0, 1, 10); fpSpread1.ActiveSheet.SetValue(1, 1, 20); fpSpread1.ActiveSheet.SetValue(2, 1, 30); fpSpread1.ActiveSheet.SetValue(3, 1, 40); fpSpread1.ActiveSheet.SetValue(4, 1, 50); fpSpread1.ActiveSheet.SetValue(5, 1, 60); fpSpread1.ActiveSheet.SetValue(6, 1, 70); fpSpread1.ActiveSheet.SetValue(7, 1, 80); fpSpread1.ActiveSheet.Columns[2].Label = "アイコンセット"; fpSpread1.ActiveSheet.Columns[2].Width = 100; fpSpread1.ActiveSheet.SetValue(0, 2, 10); fpSpread1.ActiveSheet.SetValue(1, 2, 20); fpSpread1.ActiveSheet.SetValue(2, 2, 30); fpSpread1.ActiveSheet.SetValue(3, 2, 40); fpSpread1.ActiveSheet.SetValue(4, 2, 50); fpSpread1.ActiveSheet.SetValue(5, 2, 60); fpSpread1.ActiveSheet.SetValue(6, 2, 70); fpSpread1.ActiveSheet.SetValue(7, 2, 80); // データバー FarPoint.Win.Spread.DatabarConditionalFormattingRule DataRule = new FarPoint.Win.Spread.DatabarConditionalFormattingRule(); DataRule.Gradient = true; FarPoint.Win.Spread.ConditionalFormatting DataCF = new FarPoint.Win.Spread.ConditionalFormatting(new FarPoint.Win.Spread.Model.CellRange(0, 0, 10, 1)); DataCF.Add(DataRule); fpSpread1.ActiveSheet.Models.ConditionalFormatting.Add(DataCF); // カラースケール FarPoint.Win.Spread.TwoColorScaleConditionalFormattingRule ColorRule = new FarPoint.Win.Spread.TwoColorScaleConditionalFormattingRule(); ColorRule.MinValue = new FarPoint.Win.Spread.ConditionalFormattingColorValue(Color.AliceBlue, null, FarPoint.Win.Spread.ConditionalFormattingValueType.Min); ColorRule.MaxValue = new FarPoint.Win.Spread.ConditionalFormattingColorValue(Color.Orange, null, FarPoint.Win.Spread.ConditionalFormattingValueType.Max); FarPoint.Win.Spread.ConditionalFormatting ColorCF = new FarPoint.Win.Spread.ConditionalFormatting(new FarPoint.Win.Spread.Model.CellRange(0, 1, 10, 1)); ColorCF.Add(ColorRule); fpSpread1.ActiveSheet.Models.ConditionalFormatting.Add(ColorCF); // アイコンセット FarPoint.Win.Spread.IconSetConditionalFormattingRule IconRule = new FarPoint.Win.Spread.IconSetConditionalFormattingRule(FarPoint.Win.Spread.ConditionalFormattingIconSetStyle.ThreeColoredArrows); FarPoint.Win.Spread.ConditionalFormatting IconCF = new FarPoint.Win.Spread.ConditionalFormatting(new FarPoint.Win.Spread.Model.CellRange(0, 2, 10, 1)); IconCF.Add(IconRule); fpSpread1.ActiveSheet.Models.ConditionalFormatting.Add(IconCF); }
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load ' データの設定 FpSpread1.ActiveSheet.Columns(0).Label = "データバー" FpSpread1.ActiveSheet.Columns(0).Width = 100 FpSpread1.ActiveSheet.SetValue(0, 0, 10) FpSpread1.ActiveSheet.SetValue(1, 0, 20) FpSpread1.ActiveSheet.SetValue(2, 0, 30) FpSpread1.ActiveSheet.SetValue(3, 0, 40) FpSpread1.ActiveSheet.SetValue(4, 0, 50) FpSpread1.ActiveSheet.SetValue(5, 0, 60) FpSpread1.ActiveSheet.SetValue(6, 0, 70) FpSpread1.ActiveSheet.SetValue(7, 0, 80) FpSpread1.ActiveSheet.Columns(1).Label = "カラースケール" FpSpread1.ActiveSheet.Columns(1).Width = 100 FpSpread1.ActiveSheet.SetValue(0, 1, 10) FpSpread1.ActiveSheet.SetValue(1, 1, 20) FpSpread1.ActiveSheet.SetValue(2, 1, 30) FpSpread1.ActiveSheet.SetValue(3, 1, 40) FpSpread1.ActiveSheet.SetValue(4, 1, 50) FpSpread1.ActiveSheet.SetValue(5, 1, 60) FpSpread1.ActiveSheet.SetValue(6, 1, 70) FpSpread1.ActiveSheet.SetValue(7, 1, 80) FpSpread1.ActiveSheet.Columns(2).Label = "アイコンセット" FpSpread1.ActiveSheet.Columns(2).Width = 100 FpSpread1.ActiveSheet.SetValue(0, 2, 10) FpSpread1.ActiveSheet.SetValue(1, 2, 20) FpSpread1.ActiveSheet.SetValue(2, 2, 30) FpSpread1.ActiveSheet.SetValue(3, 2, 40) FpSpread1.ActiveSheet.SetValue(4, 2, 50) FpSpread1.ActiveSheet.SetValue(5, 2, 60) FpSpread1.ActiveSheet.SetValue(6, 2, 70) FpSpread1.ActiveSheet.SetValue(7, 2, 80) ' データバー Dim DataRule As New FarPoint.Win.Spread.DatabarConditionalFormattingRule() DataRule.Gradient = True Dim DataCF As New FarPoint.Win.Spread.ConditionalFormatting(New FarPoint.Win.Spread.Model.CellRange(0, 0, 10, 1)) DataCF.Add(DataRule) FpSpread1.ActiveSheet.Models.ConditionalFormatting.Add(DataCF) ' カラースケール Dim ColorRule As New FarPoint.Win.Spread.TwoColorScaleConditionalFormattingRule() ColorRule.MinValue = New FarPoint.Win.Spread.ConditionalFormattingColorValue(Color.AliceBlue, Nothing, FarPoint.Win.Spread.ConditionalFormattingValueType.Min) ColorRule.MaxValue = New FarPoint.Win.Spread.ConditionalFormattingColorValue(Color.Orange, Nothing, FarPoint.Win.Spread.ConditionalFormattingValueType.Max) Dim ColorCF As New FarPoint.Win.Spread.ConditionalFormatting(New FarPoint.Win.Spread.Model.CellRange(0, 1, 10, 1)) ColorCF.Add(ColorRule) FpSpread1.ActiveSheet.Models.ConditionalFormatting.Add(ColorCF) ' アイコンセット Dim IconRule As New FarPoint.Win.Spread.IconSetConditionalFormattingRule(FarPoint.Win.Spread.ConditionalFormattingIconSetStyle.ThreeColoredArrows) Dim IconCF As New FarPoint.Win.Spread.ConditionalFormatting(New FarPoint.Win.Spread.Model.CellRange(0, 2, 10, 1)) IconCF.Add(IconRule) FpSpread1.ActiveSheet.Models.ConditionalFormatting.Add(IconCF) End Sub