コード例 #1
0
        internal SLConditionalFormattingRule Clone()
        {
            SLConditionalFormattingRule cfr = new SLConditionalFormattingRule();

            cfr.Formulas = new List <Formula>();
            for (int i = 0; i < this.Formulas.Count; ++i)
            {
                cfr.Formulas.Add((Formula)this.Formulas[i].CloneNode(true));
            }

            cfr.HasColorScale = this.HasColorScale;
            cfr.ColorScale    = this.ColorScale.Clone();
            cfr.HasDataBar    = this.HasDataBar;
            cfr.DataBar       = this.DataBar.Clone();
            cfr.HasIconSet    = this.HasIconSet;
            cfr.IconSet       = this.IconSet.Clone();

            cfr.Extensions = new List <ConditionalFormattingRuleExtension>();
            for (int i = 0; i < this.Extensions.Count; ++i)
            {
                cfr.Extensions.Add((ConditionalFormattingRuleExtension)this.Extensions[i].CloneNode(true));
            }

            cfr.Type     = this.Type;
            cfr.FormatId = this.FormatId;
            cfr.HasDifferentialFormat = this.HasDifferentialFormat;
            cfr.DifferentialFormat    = this.DifferentialFormat.Clone();

            cfr.Priority     = this.Priority;
            cfr.StopIfTrue   = this.StopIfTrue;
            cfr.AboveAverage = this.AboveAverage;
            cfr.Percent      = this.Percent;
            cfr.Bottom       = this.Bottom;

            cfr.HasOperator   = this.HasOperator;
            cfr.Operator      = this.Operator;
            cfr.Text          = this.Text;
            cfr.HasTimePeriod = this.HasTimePeriod;
            cfr.TimePeriod    = this.TimePeriod;
            cfr.Rank          = this.Rank;
            cfr.StdDev        = this.StdDev;
            cfr.EqualAverage  = this.EqualAverage;

            return(cfr);
        }
コード例 #2
0
        private void HighlightCellsContainingErrors(bool ContainsErrors, SLDifferentialFormat HighlightStyle)
        {
            SLConditionalFormattingRule cfr = new SLConditionalFormattingRule();

            Formula f = new Formula();
            string sRef = string.Empty;
            if (this.SequenceOfReferences.Count > 0)
            {
                sRef = SLTool.ToCellReference(this.SequenceOfReferences[0].StartRowIndex, this.SequenceOfReferences[0].StartColumnIndex);
            }
            if (ContainsErrors)
            {
                cfr.Type = ConditionalFormatValues.ContainsErrors;
                f.Text = string.Format("ISERROR({0})", sRef);
            }
            else
            {
                cfr.Type = ConditionalFormatValues.NotContainsErrors;
                f.Text = string.Format("NOT(ISERROR({0}))", sRef);
            }
            cfr.Formulas.Add(f);

            cfr.DifferentialFormat = HighlightStyle.Clone();
            cfr.HasDifferentialFormat = true;

            this.AppendRule(cfr);
        }
コード例 #3
0
        private void HighlightCellsBetween(bool IsBetween, string Value1, string Value2, SLDifferentialFormat HighlightStyle)
        {
            SLConditionalFormattingRule cfr = new SLConditionalFormattingRule();
            cfr.Type = ConditionalFormatValues.CellIs;
            cfr.Operator = IsBetween ? ConditionalFormattingOperatorValues.Between : ConditionalFormattingOperatorValues.NotBetween;
            cfr.HasOperator = true;

            cfr.Formulas.Add(this.GetFormulaFromText(Value1));
            cfr.Formulas.Add(this.GetFormulaFromText(Value2));

            cfr.DifferentialFormat = HighlightStyle.Clone();
            cfr.HasDifferentialFormat = true;

            this.AppendRule(cfr);
        }
コード例 #4
0
        private void HighlightCellsAboveAverage(SLHighlightCellsAboveAverageValues AverageType, SLDifferentialFormat HighlightStyle)
        {
            SLConditionalFormattingRule cfr = new SLConditionalFormattingRule();
            cfr.Type = ConditionalFormatValues.AboveAverage;

            switch (AverageType)
            {
                case SLHighlightCellsAboveAverageValues.Above:
                    // that's all is needed!
                    break;
                case SLHighlightCellsAboveAverageValues.Below:
                    cfr.AboveAverage = false;
                    break;
                case SLHighlightCellsAboveAverageValues.EqualOrAbove:
                    cfr.EqualAverage = true;
                    break;
                case SLHighlightCellsAboveAverageValues.EqualOrBelow:
                    cfr.EqualAverage = true;
                    cfr.AboveAverage = false;
                    break;
                case SLHighlightCellsAboveAverageValues.OneStdDevAbove:
                    cfr.StdDev = 1;
                    break;
                case SLHighlightCellsAboveAverageValues.OneStdDevBelow:
                    cfr.AboveAverage = false;
                    cfr.StdDev = 1;
                    break;
                case SLHighlightCellsAboveAverageValues.TwoStdDevAbove:
                    cfr.StdDev = 2;
                    break;
                case SLHighlightCellsAboveAverageValues.TwoStdDevBelow:
                    cfr.AboveAverage = false;
                    cfr.StdDev = 2;
                    break;
                case SLHighlightCellsAboveAverageValues.ThreeStdDevAbove:
                    cfr.StdDev = 3;
                    break;
                case SLHighlightCellsAboveAverageValues.ThreeStdDevBelow:
                    cfr.AboveAverage = false;
                    cfr.StdDev = 3;
                    break;
            }

            cfr.DifferentialFormat = HighlightStyle.Clone();
            cfr.HasDifferentialFormat = true;

            this.AppendRule(cfr);
        }
コード例 #5
0
        /// <summary>
        /// Set a custom 3-icon set.
        /// </summary>
        /// <param name="IconSetType">The type of 3-icon set.</param>
        /// <param name="ReverseIconOrder">True to reverse the order of the icons. False to use the default order.</param>
        /// <param name="ShowIconOnly">True to show only icons. False to show both icon and value.</param>
        /// <param name="GreaterThanOrEqual2">True if values are to be greater than or equal to the 2nd range value. False if values are to be strictly greater than.</param>
        /// <param name="Value2">The 2nd range value.</param>
        /// <param name="Type2">The conditional format type for the 2nd range value.</param>
        /// <param name="GreaterThanOrEqual3">True if values are to be greater than or equal to the 3rd range value. False if values are to be strictly greater than.</param>
        /// <param name="Value3">The 3rd range value.</param>
        /// <param name="Type3">The conditional format type for the 3rd range value.</param>
        public void SetCustomIconSet(SLThreeIconSetValues IconSetType, bool ReverseIconOrder, bool ShowIconOnly,
            bool GreaterThanOrEqual2, string Value2, SLConditionalFormatRangeValues Type2,
            bool GreaterThanOrEqual3, string Value3, SLConditionalFormatRangeValues Type3)
        {
            SLConditionalFormattingRule cfr = new SLConditionalFormattingRule();
            cfr.Type = ConditionalFormatValues.IconSet;
            cfr.IconSet.Reverse = ReverseIconOrder;
            cfr.IconSet.ShowValue = !ShowIconOnly;

            switch (IconSetType)
            {
                case SLThreeIconSetValues.ThreeArrows:
                    cfr.IconSet.IconSetValue = IconSetValues.ThreeArrows;
                    break;
                case SLThreeIconSetValues.ThreeArrowsGray:
                    cfr.IconSet.IconSetValue = IconSetValues.ThreeArrowsGray;
                    break;
                case SLThreeIconSetValues.ThreeFlags:
                    cfr.IconSet.IconSetValue = IconSetValues.ThreeFlags;
                    break;
                case SLThreeIconSetValues.ThreeSigns:
                    cfr.IconSet.IconSetValue = IconSetValues.ThreeSigns;
                    break;
                case SLThreeIconSetValues.ThreeSymbols:
                    cfr.IconSet.IconSetValue = IconSetValues.ThreeSymbols;
                    break;
                case SLThreeIconSetValues.ThreeSymbols2:
                    cfr.IconSet.IconSetValue = IconSetValues.ThreeSymbols2;
                    break;
                case SLThreeIconSetValues.ThreeTrafficLights1:
                    cfr.IconSet.IconSetValue = IconSetValues.ThreeTrafficLights1;
                    break;
                case SLThreeIconSetValues.ThreeTrafficLights2:
                    cfr.IconSet.IconSetValue = IconSetValues.ThreeTrafficLights2;
                    break;
            }

            SLConditionalFormatValueObject cfvo;

            cfvo = new SLConditionalFormatValueObject();
            cfvo.Type = ConditionalFormatValueObjectValues.Percent;
            cfvo.Val = "0";
            cfr.IconSet.Cfvos.Add(cfvo);

            cfvo = new SLConditionalFormatValueObject();
            cfvo.Type = this.TranslateRangeValues(Type2);
            cfvo.Val = Value2;
            cfvo.GreaterThanOrEqual = GreaterThanOrEqual2;
            cfr.IconSet.Cfvos.Add(cfvo);

            cfvo = new SLConditionalFormatValueObject();
            cfvo.Type = this.TranslateRangeValues(Type3);
            cfvo.Val = Value3;
            cfvo.GreaterThanOrEqual = GreaterThanOrEqual3;
            cfr.IconSet.Cfvos.Add(cfvo);

            cfr.HasIconSet = true;

            this.AppendRule(cfr);
        }
コード例 #6
0
        private void HighlightCellsWithUniques(SLDifferentialFormat HighlightStyle)
        {
            SLConditionalFormattingRule cfr = new SLConditionalFormattingRule();
            cfr.Type = ConditionalFormatValues.UniqueValues;

            cfr.DifferentialFormat = HighlightStyle.Clone();
            cfr.HasDifferentialFormat = true;

            this.AppendRule(cfr);
        }
コード例 #7
0
        private void HighlightCellsWithDatesOccurring(TimePeriodValues DatePeriod, SLDifferentialFormat HighlightStyle)
        {
            SLConditionalFormattingRule cfr = new SLConditionalFormattingRule();
            cfr.Type = ConditionalFormatValues.TimePeriod;
            cfr.TimePeriod = DatePeriod;
            cfr.HasTimePeriod = true;

            Formula f = new Formula();
            string sRef = string.Empty;
            if (this.SequenceOfReferences.Count > 0)
            {
                sRef = SLTool.ToCellReference(this.SequenceOfReferences[0].StartRowIndex, this.SequenceOfReferences[0].StartColumnIndex);
            }
            switch (DatePeriod)
            {
                case TimePeriodValues.Yesterday:
                    f.Text = string.Format("FLOOR({0},1)=TODAY()-1", sRef);
                    break;
                case TimePeriodValues.Today:
                    f.Text = string.Format("FLOOR({0},1)=TODAY()", sRef);
                    break;
                case TimePeriodValues.Tomorrow:
                    f.Text = string.Format("FLOOR({0},1)=TODAY()+1", sRef);
                    break;
                case TimePeriodValues.Last7Days:
                    f.Text = string.Format("AND(TODAY()-FLOOR({0},1)<=6,FLOOR({0},1)<=TODAY())", sRef);
                    break;
                case TimePeriodValues.LastWeek:
                    f.Text = string.Format("AND(TODAY()-ROUNDDOWN({0},0)>=(WEEKDAY(TODAY())),TODAY()-ROUNDDOWN({0},0)<(WEEKDAY(TODAY())+7))", sRef);
                    break;
                case TimePeriodValues.ThisWeek:
                    f.Text = string.Format("AND(TODAY()-ROUNDDOWN({0},0)<=WEEKDAY(TODAY())-1,ROUNDDOWN({0},0)-TODAY()<=7-WEEKDAY(TODAY()))", sRef);
                    break;
                case TimePeriodValues.NextWeek:
                    f.Text = string.Format("AND(ROUNDDOWN({0},0)-TODAY()>(7-WEEKDAY(TODAY())),ROUNDDOWN({0},0)-TODAY()<(15-WEEKDAY(TODAY())))", sRef);
                    break;
                case TimePeriodValues.LastMonth:
                    f.Text = string.Format("AND(MONTH({0})=MONTH(EDATE(TODAY(),0-1)),YEAR({0})=YEAR(EDATE(TODAY(),0-1)))", sRef);
                    break;
                case TimePeriodValues.ThisMonth:
                    f.Text = string.Format("AND(MONTH({0})=MONTH(TODAY()),YEAR({0})=YEAR(TODAY()))", sRef);
                    break;
                case TimePeriodValues.NextMonth:
                    f.Text = string.Format("AND(MONTH({0})=MONTH(TODAY())+1,OR(YEAR({0})=YEAR(TODAY()),AND(MONTH({0})=12,YEAR({0})=YEAR(TODAY())+1)))", sRef);
                    break;
            }
            cfr.Formulas.Add(f);

            cfr.DifferentialFormat = HighlightStyle.Clone();
            cfr.HasDifferentialFormat = true;

            this.AppendRule(cfr);
        }
コード例 #8
0
        private void HighlightCellsInTopRange(bool IsTopRange, uint Rank, bool IsPercent, SLDifferentialFormat HighlightStyle)
        {
            SLConditionalFormattingRule cfr = new SLConditionalFormattingRule();
            cfr.Type = ConditionalFormatValues.Top10;
            cfr.Bottom = !IsTopRange;
            cfr.Rank = Rank;
            cfr.Percent = IsPercent;

            cfr.DifferentialFormat = HighlightStyle.Clone();
            cfr.HasDifferentialFormat = true;

            this.AppendRule(cfr);
        }
コード例 #9
0
        /// <summary>
        /// Set a color scale formatting with built-in types.
        /// </summary>
        /// <param name="ColorScale">A built-in color scale type.</param>
        public void SetColorScale(SLConditionalFormatColorScaleValues ColorScale)
        {
            SLConditionalFormattingRule cfr = new SLConditionalFormattingRule();
            cfr.Type = ConditionalFormatValues.ColorScale;
            cfr.ColorScale.Cfvos.Add(new SLConditionalFormatValueObject()
            {
                Type = ConditionalFormatValueObjectValues.Min //Excel 2010 omits this: , Val = "0"
            });
            if (ColorScale == SLConditionalFormatColorScaleValues.GreenYellowRed
                || ColorScale == SLConditionalFormatColorScaleValues.RedYellowGreen
                || ColorScale == SLConditionalFormatColorScaleValues.BlueYellowRed
                || ColorScale == SLConditionalFormatColorScaleValues.RedYellowBlue
                || ColorScale == SLConditionalFormatColorScaleValues.GreenWhiteRed
                || ColorScale == SLConditionalFormatColorScaleValues.RedWhiteGreen
                || ColorScale == SLConditionalFormatColorScaleValues.BlueWhiteRed
                || ColorScale == SLConditionalFormatColorScaleValues.RedWhiteBlue)
            {
                cfr.ColorScale.Cfvos.Add(new SLConditionalFormatValueObject()
                {
                    Type = ConditionalFormatValueObjectValues.Percentile,
                    Val = "50"
                });
            }
            cfr.ColorScale.Cfvos.Add(new SLConditionalFormatValueObject()
            {
                Type = ConditionalFormatValueObjectValues.Max //Excel 2010 omits this: , Val = "0"
            });

            List<System.Drawing.Color> listempty = new List<System.Drawing.Color>();
            switch (ColorScale)
            {
                case SLConditionalFormatColorScaleValues.GreenYellowRed:
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0xF8, 0x69, 0x6B) });
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0xFF, 0xEB, 0x84) });
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0x63, 0xBE, 0x7B) });
                    break;
                case SLConditionalFormatColorScaleValues.RedYellowGreen:
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0x63, 0xBE, 0x7B) });
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0xFF, 0xEB, 0x84) });
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0xF8, 0x69, 0x6B) });
                    break;
                case SLConditionalFormatColorScaleValues.BlueYellowRed:
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0xF8, 0x69, 0x6B) });
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0xFF, 0xEB, 0x84) });
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0x5A, 0x8A, 0xC6) });
                    break;
                case SLConditionalFormatColorScaleValues.RedYellowBlue:
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0x5A, 0x8A, 0xC6) });
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0xFF, 0xEB, 0x84) });
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0xF8, 0x69, 0x6B) });
                    break;
                case SLConditionalFormatColorScaleValues.GreenWhiteRed:
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0xF8, 0x69, 0x6B) });
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0xFC, 0xFC, 0xFF) });
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0x63, 0xBE, 0x7B) });
                    break;
                case SLConditionalFormatColorScaleValues.RedWhiteGreen:
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0x63, 0xBE, 0x7B) });
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0xFC, 0xFC, 0xFF) });
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0xF8, 0x69, 0x6B) });
                    break;
                case SLConditionalFormatColorScaleValues.BlueWhiteRed:
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0xF8, 0x69, 0x6B) });
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0xFC, 0xFC, 0xFF) });
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0x5A, 0x8A, 0xC6) });
                    break;
                case SLConditionalFormatColorScaleValues.RedWhiteBlue:
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0x5A, 0x8A, 0xC6) });
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0xFC, 0xFC, 0xFF) });
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0xF8, 0x69, 0x6B) });
                    break;
                case SLConditionalFormatColorScaleValues.WhiteRed:
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0xF8, 0x69, 0x6B) });
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0xFC, 0xFC, 0xFF) });
                    break;
                case SLConditionalFormatColorScaleValues.RedWhite:
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0xFC, 0xFC, 0xFF) });
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0xF8, 0x69, 0x6B) });
                    break;
                case SLConditionalFormatColorScaleValues.GreenWhite:
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0xFC, 0xFC, 0xFF) });
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0x63, 0xBE, 0x7B) });
                    break;
                case SLConditionalFormatColorScaleValues.WhiteGreen:
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0x63, 0xBE, 0x7B) });
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0xFC, 0xFC, 0xFF) });
                    break;
                case SLConditionalFormatColorScaleValues.YellowRed:
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0xFF, 0x71, 0x28) });
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0xFF, 0xEF, 0x9C) });
                    break;
                case SLConditionalFormatColorScaleValues.RedYellow:
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0xFF, 0xEF, 0x9C) });
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0xFF, 0x71, 0x28) });
                    break;
                case SLConditionalFormatColorScaleValues.GreenYellow:
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0xFF, 0xEF, 0x9C) });
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0x63, 0xBE, 0x7B) });
                    break;
                case SLConditionalFormatColorScaleValues.YellowGreen:
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0x63, 0xBE, 0x7B) });
                    cfr.ColorScale.Colors.Add(new SLColor(listempty, listempty) { Color = System.Drawing.Color.FromArgb(0xFF, 0xFF, 0xEF, 0x9C) });
                    break;
            }

            cfr.HasColorScale = true;

            this.AppendRule(cfr);
        }
コード例 #10
0
        internal SLConditionalFormattingRule Clone()
        {
            SLConditionalFormattingRule cfr = new SLConditionalFormattingRule();

            cfr.Formulas = new List<Formula>();
            for (int i = 0; i < this.Formulas.Count; ++i)
            {
                cfr.Formulas.Add((Formula)this.Formulas[i].CloneNode(true));
            }

            cfr.HasColorScale = this.HasColorScale;
            cfr.ColorScale = this.ColorScale.Clone();
            cfr.HasDataBar = this.HasDataBar;
            cfr.DataBar = this.DataBar.Clone();
            cfr.HasIconSet = this.HasIconSet;
            cfr.IconSet = this.IconSet.Clone();

            cfr.Extensions = new List<ConditionalFormattingRuleExtension>();
            for (int i = 0; i < this.Extensions.Count; ++i)
            {
                cfr.Extensions.Add((ConditionalFormattingRuleExtension)this.Extensions[i].CloneNode(true));
            }

            cfr.Type = this.Type;
            cfr.FormatId = this.FormatId;
            cfr.HasDifferentialFormat = this.HasDifferentialFormat;
            cfr.DifferentialFormat = this.DifferentialFormat.Clone();

            cfr.Priority = this.Priority;
            cfr.StopIfTrue = this.StopIfTrue;
            cfr.AboveAverage = this.AboveAverage;
            cfr.Percent = this.Percent;
            cfr.Bottom = this.Bottom;

            cfr.HasOperator = this.HasOperator;
            cfr.Operator = this.Operator;
            cfr.Text = this.Text;
            cfr.HasTimePeriod = this.HasTimePeriod;
            cfr.TimePeriod = this.TimePeriod;
            cfr.Rank = this.Rank;
            cfr.StdDev = this.StdDev;
            cfr.EqualAverage = this.EqualAverage;

            return cfr;
        }
コード例 #11
0
        private void SetCustomDataBar(bool ShowBarOnly, uint MinLength, uint MaxLength, SLConditionalFormatMinMaxValues ShortestBarType, string ShortestBarValue, SLConditionalFormatMinMaxValues LongestBarType, string LongestBarValue, SLColor BarColor)
        {
            SLConditionalFormattingRule cfr = new SLConditionalFormattingRule();
            cfr.Type = ConditionalFormatValues.DataBar;
            cfr.DataBar.ShowValue = !ShowBarOnly;
            cfr.DataBar.MinLength = MinLength;
            cfr.DataBar.MaxLength = MaxLength;

            switch (ShortestBarType)
            {
                case SLConditionalFormatMinMaxValues.Value:
                    cfr.DataBar.Cfvo1.Type = ConditionalFormatValueObjectValues.Min;
                    break;
                case SLConditionalFormatMinMaxValues.Number:
                    cfr.DataBar.Cfvo1.Type = ConditionalFormatValueObjectValues.Number;
                    break;
                case SLConditionalFormatMinMaxValues.Percent:
                    cfr.DataBar.Cfvo1.Type = ConditionalFormatValueObjectValues.Percent;
                    break;
                case SLConditionalFormatMinMaxValues.Formula:
                    cfr.DataBar.Cfvo1.Type = ConditionalFormatValueObjectValues.Formula;
                    break;
                case SLConditionalFormatMinMaxValues.Percentile:
                    cfr.DataBar.Cfvo1.Type = ConditionalFormatValueObjectValues.Percentile;
                    break;
            }
            cfr.DataBar.Cfvo1.Val = ShortestBarValue;
            switch (LongestBarType)
            {
                case SLConditionalFormatMinMaxValues.Value:
                    cfr.DataBar.Cfvo2.Type = ConditionalFormatValueObjectValues.Max;
                    break;
                case SLConditionalFormatMinMaxValues.Number:
                    cfr.DataBar.Cfvo2.Type = ConditionalFormatValueObjectValues.Number;
                    break;
                case SLConditionalFormatMinMaxValues.Percent:
                    cfr.DataBar.Cfvo2.Type = ConditionalFormatValueObjectValues.Percent;
                    break;
                case SLConditionalFormatMinMaxValues.Formula:
                    cfr.DataBar.Cfvo2.Type = ConditionalFormatValueObjectValues.Formula;
                    break;
                case SLConditionalFormatMinMaxValues.Percentile:
                    cfr.DataBar.Cfvo2.Type = ConditionalFormatValueObjectValues.Percentile;
                    break;
            }
            cfr.DataBar.Cfvo2.Val = LongestBarValue;

            cfr.DataBar.Color = BarColor.Clone();

            cfr.HasDataBar = true;

            this.AppendRule(cfr);
        }
コード例 #12
0
        /// <summary>
        /// Set a data bar formatting with built-in types.
        /// </summary>
        /// <param name="DataBar">A built-in data bar type.</param>
        public void SetDataBar(SLConditionalFormatDataBarValues DataBar)
        {
            SLConditionalFormattingRule cfr = new SLConditionalFormattingRule();
            cfr.Type = ConditionalFormatValues.DataBar;
            cfr.DataBar.Cfvo1.Type = ConditionalFormatValueObjectValues.Min;
            cfr.DataBar.Cfvo1.Val = "0";
            cfr.DataBar.Cfvo2.Type = ConditionalFormatValueObjectValues.Max;
            cfr.DataBar.Cfvo2.Val = "0";

            switch (DataBar)
            {
                case SLConditionalFormatDataBarValues.Blue:
                    cfr.DataBar.Color.Color = System.Drawing.Color.FromArgb(0xFF, 0x63, 0x8E, 0xC6);
                    break;
                case SLConditionalFormatDataBarValues.Green:
                    cfr.DataBar.Color.Color = System.Drawing.Color.FromArgb(0xFF, 0x63, 0xC3, 0x84);
                    break;
                case SLConditionalFormatDataBarValues.Red:
                    cfr.DataBar.Color.Color = System.Drawing.Color.FromArgb(0xFF, 0xFF, 0x55, 0x5A);
                    break;
                case SLConditionalFormatDataBarValues.Orange:
                    cfr.DataBar.Color.Color = System.Drawing.Color.FromArgb(0xFF, 0xFF, 0xB6, 0x28);
                    break;
                case SLConditionalFormatDataBarValues.LightBlue:
                    cfr.DataBar.Color.Color = System.Drawing.Color.FromArgb(0xFF, 0x00, 0x8A, 0xEF);
                    break;
                case SLConditionalFormatDataBarValues.Purple:
                    cfr.DataBar.Color.Color = System.Drawing.Color.FromArgb(0xFF, 0xD6, 0x00, 0x7B);
                    break;
            }

            cfr.HasDataBar = true;

            this.AppendRule(cfr);
        }
コード例 #13
0
        internal void FromConditionalFormatting(ConditionalFormatting cf)
        {
            this.SetAllNull();

            if (cf.Pivot != null) this.Pivot = cf.Pivot.Value;

            SLCellPointRange pt;
            int index;
            int iStartRowIndex = -1;
            int iStartColumnIndex = -1;
            int iEndRowIndex = -1;
            int iEndColumnIndex = -1;
            foreach (var s in cf.SequenceOfReferences.Items)
            {
                index = s.Value.IndexOf(":");
                if (index > -1)
                {
                    if (SLTool.FormatCellReferenceRangeToRowColumnIndex(s.Value, out iStartRowIndex, out iStartColumnIndex, out iEndRowIndex, out iEndColumnIndex))
                    {
                        pt = new SLCellPointRange(iStartRowIndex, iStartColumnIndex, iEndRowIndex, iEndColumnIndex);
                        this.SequenceOfReferences.Add(pt);
                    }
                }
                else
                {
                    if (SLTool.FormatCellReferenceToRowColumnIndex(s.Value, out iStartRowIndex, out iStartColumnIndex))
                    {
                        pt = new SLCellPointRange(iStartRowIndex, iStartColumnIndex, iStartRowIndex, iStartColumnIndex);
                        this.SequenceOfReferences.Add(pt);
                    }
                }
            }

            foreach (var rule in cf.Elements<ConditionalFormattingRule>())
            {
                var cfr = new SLConditionalFormattingRule();
                cfr.FromConditionalFormattingRule(rule);
                this.Rules.Add(cfr);
            }
        }
コード例 #14
0
        /// <summary>
        /// Set a custom 5-icon set.
        /// </summary>
        /// <param name="IconSetType">The type of 3-icon set.</param>
        /// <param name="ReverseIconOrder">True to reverse the order of the icons. False to use the default order.</param>
        /// <param name="ShowIconOnly">True to show only icons. False to show both icon and value.</param>
        /// <param name="GreaterThanOrEqual2">True if values are to be greater than or equal to the 2nd range value. False if values are to be strictly greater than.</param>
        /// <param name="Value2">The 2nd range value.</param>
        /// <param name="Type2">The conditional format type for the 2nd range value.</param>
        /// <param name="GreaterThanOrEqual3">True if values are to be greater than or equal to the 3rd range value. False if values are to be strictly greater than.</param>
        /// <param name="Value3">The 3rd range value.</param>
        /// <param name="Type3">The conditional format type for the 3rd range value.</param>
        /// <param name="GreaterThanOrEqual4">True if values are to be greater than or equal to the 4th range value. False if values are to be strictly greater than.</param>
        /// <param name="Value4">The 4th range value.</param>
        /// <param name="Type4">The conditional format type for the 4th range value.</param>
        /// <param name="GreaterThanOrEqual5">True if values are to be greater than or equal to the 5th range value. False if values are to be strictly greater than.</param>
        /// <param name="Value5">The 5th range value.</param>
        /// <param name="Type5">The conditional format type for the 5th range value.</param>
        public void SetCustomIconSet(SLFiveIconSetValues IconSetType, bool ReverseIconOrder, bool ShowIconOnly,
            bool GreaterThanOrEqual2, string Value2, SLConditionalFormatRangeValues Type2,
            bool GreaterThanOrEqual3, string Value3, SLConditionalFormatRangeValues Type3,
            bool GreaterThanOrEqual4, string Value4, SLConditionalFormatRangeValues Type4,
            bool GreaterThanOrEqual5, string Value5, SLConditionalFormatRangeValues Type5)
        {
            SLConditionalFormattingRule cfr = new SLConditionalFormattingRule();
            cfr.Type = ConditionalFormatValues.IconSet;
            cfr.IconSet.Reverse = ReverseIconOrder;
            cfr.IconSet.ShowValue = !ShowIconOnly;

            switch (IconSetType)
            {
                case SLFiveIconSetValues.FiveArrows:
                    cfr.IconSet.IconSetValue = IconSetValues.FiveArrows;
                    break;
                case SLFiveIconSetValues.FiveArrowsGray:
                    cfr.IconSet.IconSetValue = IconSetValues.FiveArrowsGray;
                    break;
                case SLFiveIconSetValues.FiveQuarters:
                    cfr.IconSet.IconSetValue = IconSetValues.FiveQuarters;
                    break;
                case SLFiveIconSetValues.FiveRating:
                    cfr.IconSet.IconSetValue = IconSetValues.FiveRating;
                    break;
            }

            SLConditionalFormatValueObject cfvo;

            cfvo = new SLConditionalFormatValueObject();
            cfvo.Type = ConditionalFormatValueObjectValues.Percent;
            cfvo.Val = "0";
            cfr.IconSet.Cfvos.Add(cfvo);

            cfvo = new SLConditionalFormatValueObject();
            cfvo.Type = this.TranslateRangeValues(Type2);
            cfvo.Val = Value2;
            cfvo.GreaterThanOrEqual = GreaterThanOrEqual2;
            cfr.IconSet.Cfvos.Add(cfvo);

            cfvo = new SLConditionalFormatValueObject();
            cfvo.Type = this.TranslateRangeValues(Type3);
            cfvo.Val = Value3;
            cfvo.GreaterThanOrEqual = GreaterThanOrEqual3;
            cfr.IconSet.Cfvos.Add(cfvo);

            cfvo = new SLConditionalFormatValueObject();
            cfvo.Type = this.TranslateRangeValues(Type4);
            cfvo.Val = Value4;
            cfvo.GreaterThanOrEqual = GreaterThanOrEqual4;
            cfr.IconSet.Cfvos.Add(cfvo);

            cfvo = new SLConditionalFormatValueObject();
            cfvo.Type = this.TranslateRangeValues(Type5);
            cfvo.Val = Value5;
            cfvo.GreaterThanOrEqual = GreaterThanOrEqual5;
            cfr.IconSet.Cfvos.Add(cfvo);

            cfr.HasIconSet = true;

            this.AppendRule(cfr);
        }
コード例 #15
0
        private void HighlightCellsContainingText(bool IsContaining, string Value, SLDifferentialFormat HighlightStyle)
        {
            SLConditionalFormattingRule cfr = new SLConditionalFormattingRule();
            cfr.Text = Value;

            Formula f = new Formula();
            string sRef = string.Empty;
            if (this.SequenceOfReferences.Count > 0)
            {
                sRef = SLTool.ToCellReference(this.SequenceOfReferences[0].StartRowIndex, this.SequenceOfReferences[0].StartColumnIndex);
            }
            if (IsContaining)
            {
                cfr.Type = ConditionalFormatValues.ContainsText;
                cfr.Operator = ConditionalFormattingOperatorValues.ContainsText;
                cfr.HasOperator = true;
                f.Text = string.Format("NOT(ISERROR(SEARCH({0},{1})))", this.GetCleanedStringFromText(Value), sRef);
            }
            else
            {
                cfr.Type = ConditionalFormatValues.NotContainsText;
                cfr.Operator = ConditionalFormattingOperatorValues.NotContains;
                cfr.HasOperator = true;
                f.Text = string.Format("ISERROR(SEARCH({0},{1}))", this.GetCleanedStringFromText(Value), sRef);
            }
            cfr.Formulas.Add(f);

            cfr.DifferentialFormat = HighlightStyle.Clone();
            cfr.HasDifferentialFormat = true;

            this.AppendRule(cfr);
        }
コード例 #16
0
        /// <summary>
        /// Set a custom data bar formatting.
        /// </summary>
        /// <param name="Options">Data bar options.</param>
        public void SetCustomDataBar(SLDataBarOptions Options)
        {
            SLConditionalFormattingRule cfr = new SLConditionalFormattingRule();
            cfr.Type = ConditionalFormatValues.DataBar;

            cfr.DataBar.Is2010 = Options.Is2010;

            cfr.DataBar.MinimumType = Options.MinimumType;
            cfr.DataBar.MinimumValue = Options.MinimumValue;
            cfr.DataBar.MaximumType = Options.MaximumType;
            cfr.DataBar.MaximumValue = Options.MaximumValue;

            cfr.DataBar.Color = Options.FillColor.Clone();
            cfr.DataBar.BorderColor = Options.BorderColor.Clone();
            cfr.DataBar.NegativeFillColor = Options.NegativeFillColor.Clone();
            cfr.DataBar.NegativeBorderColor = Options.NegativeBorderColor.Clone();
            cfr.DataBar.AxisColor = Options.AxisColor.Clone();

            cfr.DataBar.MinLength = Options.MinLength;
            cfr.DataBar.MaxLength = Options.MaxLength;
            cfr.DataBar.ShowValue = !Options.ShowBarOnly;
            cfr.DataBar.Border = Options.Border;
            cfr.DataBar.Gradient = Options.Gradient;
            cfr.DataBar.Direction = Options.Direction;
            cfr.DataBar.NegativeBarColorSameAsPositive = Options.NegativeBarColorSameAsPositive;
            cfr.DataBar.NegativeBarBorderColorSameAsPositive = Options.NegativeBarBorderColorSameAsPositive;
            cfr.DataBar.AxisPosition = Options.AxisPosition;

            cfr.HasDataBar = true;

            this.AppendRule(cfr);
        }
コード例 #17
0
        private void HighlightCellsEndingWith(string Value, SLDifferentialFormat HighlightStyle)
        {
            SLConditionalFormattingRule cfr = new SLConditionalFormattingRule();
            cfr.Text = Value;

            Formula f = new Formula();
            string sRef = string.Empty;
            if (this.SequenceOfReferences.Count > 0)
            {
                sRef = SLTool.ToCellReference(this.SequenceOfReferences[0].StartRowIndex, this.SequenceOfReferences[0].StartColumnIndex);
            }
            cfr.Type = ConditionalFormatValues.EndsWith;
            cfr.Operator = ConditionalFormattingOperatorValues.EndsWith;
            cfr.HasOperator = true;
            f.Text = string.Format("RIGHT({0},{1})={2}", sRef, Value.Length, this.GetCleanedStringFromText(Value));
            cfr.Formulas.Add(f);

            cfr.DifferentialFormat = HighlightStyle.Clone();
            cfr.HasDifferentialFormat = true;

            this.AppendRule(cfr);
        }
コード例 #18
0
        /// <summary>
        /// Set a custom 5-icon set.
        /// </summary>
        /// <param name="Options">5-icon set options.</param>
        public void SetCustomIconSet(SLFiveIconSetOptions Options)
        {
            SLConditionalFormattingRule cfr = new SLConditionalFormattingRule();
            cfr.Type = ConditionalFormatValues.IconSet;
            cfr.IconSet.Reverse = Options.ReverseIconOrder;
            cfr.IconSet.ShowValue = !Options.ShowIconOnly;

            switch (Options.IconSetType)
            {
                case SLFiveIconSetValues.FiveArrows:
                    cfr.IconSet.IconSetType = SLIconSetValues.FiveArrows;
                    break;
                case SLFiveIconSetValues.FiveArrowsGray:
                    cfr.IconSet.IconSetType = SLIconSetValues.FiveArrowsGray;
                    break;
                case SLFiveIconSetValues.FiveBoxes:
                    cfr.IconSet.IconSetType = SLIconSetValues.FiveBoxes;
                    break;
                case SLFiveIconSetValues.FiveQuarters:
                    cfr.IconSet.IconSetType = SLIconSetValues.FiveQuarters;
                    break;
                case SLFiveIconSetValues.FiveRating:
                    cfr.IconSet.IconSetType = SLIconSetValues.FiveRating;
                    break;
            }

            cfr.IconSet.Is2010 = SLIconSet.Is2010IconSet(cfr.IconSet.IconSetType);

            if (Options.IsCustomIcon)
            {
                X14.IconSetTypeValues istv = X14.IconSetTypeValues.ThreeTrafficLights1;
                uint iIconId = 0;

                SLIconSet.TranslateCustomIcon(Options.Icon1, out istv, out iIconId);
                cfr.IconSet.CustomIcons.Add(new SLConditionalFormattingIcon2010() { IconSet = istv, IconId = iIconId });

                SLIconSet.TranslateCustomIcon(Options.Icon2, out istv, out iIconId);
                cfr.IconSet.CustomIcons.Add(new SLConditionalFormattingIcon2010() { IconSet = istv, IconId = iIconId });

                SLIconSet.TranslateCustomIcon(Options.Icon3, out istv, out iIconId);
                cfr.IconSet.CustomIcons.Add(new SLConditionalFormattingIcon2010() { IconSet = istv, IconId = iIconId });

                SLIconSet.TranslateCustomIcon(Options.Icon4, out istv, out iIconId);
                cfr.IconSet.CustomIcons.Add(new SLConditionalFormattingIcon2010() { IconSet = istv, IconId = iIconId });

                SLIconSet.TranslateCustomIcon(Options.Icon5, out istv, out iIconId);
                cfr.IconSet.CustomIcons.Add(new SLConditionalFormattingIcon2010() { IconSet = istv, IconId = iIconId });

                cfr.IconSet.Is2010 = true;
            }

            SLConditionalFormatValueObject cfvo;

            cfvo = new SLConditionalFormatValueObject();
            cfvo.Type = ConditionalFormatValueObjectValues.Percent;
            cfvo.Val = "0";
            cfr.IconSet.Cfvos.Add(cfvo);

            cfvo = new SLConditionalFormatValueObject();
            cfvo.Type = this.TranslateRangeValues(Options.Type2);
            cfvo.Val = Options.Value2;
            cfvo.GreaterThanOrEqual = Options.GreaterThanOrEqual2;
            cfr.IconSet.Cfvos.Add(cfvo);

            cfvo = new SLConditionalFormatValueObject();
            cfvo.Type = this.TranslateRangeValues(Options.Type3);
            cfvo.Val = Options.Value3;
            cfvo.GreaterThanOrEqual = Options.GreaterThanOrEqual3;
            cfr.IconSet.Cfvos.Add(cfvo);

            cfvo = new SLConditionalFormatValueObject();
            cfvo.Type = this.TranslateRangeValues(Options.Type4);
            cfvo.Val = Options.Value4;
            cfvo.GreaterThanOrEqual = Options.GreaterThanOrEqual4;
            cfr.IconSet.Cfvos.Add(cfvo);

            cfvo = new SLConditionalFormatValueObject();
            cfvo.Type = this.TranslateRangeValues(Options.Type5);
            cfvo.Val = Options.Value5;
            cfvo.GreaterThanOrEqual = Options.GreaterThanOrEqual5;
            cfr.IconSet.Cfvos.Add(cfvo);

            cfr.HasIconSet = true;

            this.AppendRule(cfr);
        }
コード例 #19
0
        private void HighlightCellsLessThan(bool IncludeEquality, string Value, SLDifferentialFormat HighlightStyle)
        {
            SLConditionalFormattingRule cfr = new SLConditionalFormattingRule();
            cfr.Type = ConditionalFormatValues.CellIs;
            cfr.Operator = IncludeEquality ? ConditionalFormattingOperatorValues.LessThanOrEqual : ConditionalFormattingOperatorValues.LessThan;
            cfr.HasOperator = true;

            cfr.Formulas.Add(this.GetFormulaFromText(Value));

            cfr.DifferentialFormat = HighlightStyle.Clone();
            cfr.HasDifferentialFormat = true;

            this.AppendRule(cfr);
        }
コード例 #20
0
        internal void FromConditionalFormatting(ConditionalFormatting cf)
        {
            this.SetAllNull();

            if (cf.Pivot != null) this.Pivot = cf.Pivot.Value;

            if (cf.SequenceOfReferences != null)
            {
                this.SequenceOfReferences = SLTool.TranslateSeqRefToCellPointRange(cf.SequenceOfReferences);
            }

            using (OpenXmlReader oxr = OpenXmlReader.Create(cf))
            {
                SLConditionalFormattingRule cfr;
                while (oxr.Read())
                {
                    if (oxr.ElementType == typeof(ConditionalFormattingRule))
                    {
                        cfr = new SLConditionalFormattingRule();
                        cfr.FromConditionalFormattingRule((ConditionalFormattingRule)oxr.LoadCurrentElement());
                        this.Rules.Add(cfr);
                    }
                }
            }
        }
コード例 #21
0
        private void HighlightCellsWithFormula(string Formula, SLDifferentialFormat HighlightStyle)
        {
            if (Formula.StartsWith("=")) Formula = Formula.Substring(1);

            SLConditionalFormattingRule cfr = new SLConditionalFormattingRule();
            cfr.Type = ConditionalFormatValues.Expression;
            cfr.Formulas.Add(new DocumentFormat.OpenXml.Spreadsheet.Formula(Formula));
            cfr.DifferentialFormat = HighlightStyle.Clone();
            cfr.HasDifferentialFormat = true;

            this.AppendRule(cfr);
        }
コード例 #22
0
 private void AppendRule(SLConditionalFormattingRule cfr)
 {
     if (this.Rules.Count > 0)
     {
         int index = this.Rules.Count - 1;
         // This follows the Excel behaviour.
         // If the last rule is of the same type, then the last rule
         // is overwritten with the newly given rule.
         if (this.Rules[index].Type == cfr.Type)
         {
             this.Rules[index] = cfr;
         }
         else
         {
             this.Rules.Add(cfr);
         }
     }
     else
     {
         this.Rules.Add(cfr);
     }
 }
コード例 #23
0
        private void SetCustomColorScale(SLConditionalFormatMinMaxValues MinType, string MinValue, SLColor MinColor,
            bool HasMidPoint, SLConditionalFormatRangeValues MidPointType, string MidPointValue, SLColor MidPointColor,
            SLConditionalFormatMinMaxValues MaxType, string MaxValue, SLColor MaxColor)
        {
            SLConditionalFormattingRule cfr = new SLConditionalFormattingRule();
            cfr.Type = ConditionalFormatValues.ColorScale;

            SLConditionalFormatValueObject cfvo;

            cfvo = new SLConditionalFormatValueObject();
            switch (MinType)
            {
                case SLConditionalFormatMinMaxValues.Value:
                    cfvo.Type = ConditionalFormatValueObjectValues.Min;
                    break;
                case SLConditionalFormatMinMaxValues.Number:
                    cfvo.Type = ConditionalFormatValueObjectValues.Number;
                    break;
                case SLConditionalFormatMinMaxValues.Percent:
                    cfvo.Type = ConditionalFormatValueObjectValues.Percent;
                    break;
                case SLConditionalFormatMinMaxValues.Formula:
                    cfvo.Type = ConditionalFormatValueObjectValues.Formula;
                    break;
                case SLConditionalFormatMinMaxValues.Percentile:
                    cfvo.Type = ConditionalFormatValueObjectValues.Percentile;
                    break;
            }
            cfvo.Val = MinValue;
            cfr.ColorScale.Cfvos.Add(cfvo);
            cfr.ColorScale.Colors.Add(MinColor.Clone());

            if (HasMidPoint)
            {
                cfvo = new SLConditionalFormatValueObject();
                switch (MidPointType)
                {
                    case SLConditionalFormatRangeValues.Number:
                        cfvo.Type = ConditionalFormatValueObjectValues.Number;
                        break;
                    case SLConditionalFormatRangeValues.Percent:
                        cfvo.Type = ConditionalFormatValueObjectValues.Percent;
                        break;
                    case SLConditionalFormatRangeValues.Formula:
                        cfvo.Type = ConditionalFormatValueObjectValues.Formula;
                        break;
                    case SLConditionalFormatRangeValues.Percentile:
                        cfvo.Type = ConditionalFormatValueObjectValues.Percentile;
                        break;
                }
                cfvo.Val = MidPointValue;
                cfr.ColorScale.Cfvos.Add(cfvo);
                cfr.ColorScale.Colors.Add(MidPointColor.Clone());
            }

            cfvo = new SLConditionalFormatValueObject();
            switch (MaxType)
            {
                case SLConditionalFormatMinMaxValues.Value:
                    cfvo.Type = ConditionalFormatValueObjectValues.Max;
                    break;
                case SLConditionalFormatMinMaxValues.Number:
                    cfvo.Type = ConditionalFormatValueObjectValues.Number;
                    break;
                case SLConditionalFormatMinMaxValues.Percent:
                    cfvo.Type = ConditionalFormatValueObjectValues.Percent;
                    break;
                case SLConditionalFormatMinMaxValues.Formula:
                    cfvo.Type = ConditionalFormatValueObjectValues.Formula;
                    break;
                case SLConditionalFormatMinMaxValues.Percentile:
                    cfvo.Type = ConditionalFormatValueObjectValues.Percentile;
                    break;
            }
            cfvo.Val = MaxValue;
            cfr.ColorScale.Cfvos.Add(cfvo);
            cfr.ColorScale.Colors.Add(MaxColor.Clone());

            cfr.HasColorScale = true;

            this.AppendRule(cfr);
        }
コード例 #24
0
        /// <summary>
        /// Set an icon set formatting with built-in types.
        /// </summary>
        /// <param name="IconSetType">A built-in icon set type.</param>
        public void SetIconSet(IconSetValues IconSetType)
        {
            SLConditionalFormattingRule cfr = new SLConditionalFormattingRule();
            cfr.Type = ConditionalFormatValues.IconSet;
            cfr.IconSet.IconSetValue = IconSetType;

            switch (IconSetType)
            {
                case IconSetValues.FiveArrows:
                case IconSetValues.FiveArrowsGray:
                case IconSetValues.FiveQuarters:
                case IconSetValues.FiveRating:
                    cfr.IconSet.Cfvos.Add(new SLConditionalFormatValueObject() { Type = ConditionalFormatValueObjectValues.Percent, Val = "0" });
                    cfr.IconSet.Cfvos.Add(new SLConditionalFormatValueObject() { Type = ConditionalFormatValueObjectValues.Percent, Val = "20" });
                    cfr.IconSet.Cfvos.Add(new SLConditionalFormatValueObject() { Type = ConditionalFormatValueObjectValues.Percent, Val = "40" });
                    cfr.IconSet.Cfvos.Add(new SLConditionalFormatValueObject() { Type = ConditionalFormatValueObjectValues.Percent, Val = "60" });
                    cfr.IconSet.Cfvos.Add(new SLConditionalFormatValueObject() { Type = ConditionalFormatValueObjectValues.Percent, Val = "80" });
                    break;
                case IconSetValues.FourArrows:
                case IconSetValues.FourArrowsGray:
                case IconSetValues.FourRating:
                case IconSetValues.FourRedToBlack:
                case IconSetValues.FourTrafficLights:
                    cfr.IconSet.Cfvos.Add(new SLConditionalFormatValueObject() { Type = ConditionalFormatValueObjectValues.Percent, Val = "0" });
                    cfr.IconSet.Cfvos.Add(new SLConditionalFormatValueObject() { Type = ConditionalFormatValueObjectValues.Percent, Val = "25" });
                    cfr.IconSet.Cfvos.Add(new SLConditionalFormatValueObject() { Type = ConditionalFormatValueObjectValues.Percent, Val = "50" });
                    cfr.IconSet.Cfvos.Add(new SLConditionalFormatValueObject() { Type = ConditionalFormatValueObjectValues.Percent, Val = "75" });
                    break;
                case IconSetValues.ThreeArrows:
                case IconSetValues.ThreeArrowsGray:
                case IconSetValues.ThreeFlags:
                case IconSetValues.ThreeSigns:
                case IconSetValues.ThreeSymbols:
                case IconSetValues.ThreeSymbols2:
                case IconSetValues.ThreeTrafficLights1:
                case IconSetValues.ThreeTrafficLights2:
                    cfr.IconSet.Cfvos.Add(new SLConditionalFormatValueObject() { Type = ConditionalFormatValueObjectValues.Percent, Val = "0" });
                    cfr.IconSet.Cfvos.Add(new SLConditionalFormatValueObject() { Type = ConditionalFormatValueObjectValues.Percent, Val = "33" });
                    cfr.IconSet.Cfvos.Add(new SLConditionalFormatValueObject() { Type = ConditionalFormatValueObjectValues.Percent, Val = "67" });
                    break;
            }

            cfr.HasIconSet = true;

            this.AppendRule(cfr);
        }