private void SetAllNull()
        {
            Formulas      = new List <Formula>();
            ColorScale    = new SLColorScale();
            HasColorScale = false;
            DataBar       = new SLDataBar();
            HasDataBar    = false;
            IconSet       = new SLIconSet();
            HasIconSet    = false;

            Extensions = new List <ConditionalFormattingRuleExtension>();

            Type = ConditionalFormatValues.DataBar;

            DifferentialFormat    = new SLDifferentialFormat();
            HasDifferentialFormat = false;

            FormatId      = null;
            Priority      = 1;
            StopIfTrue    = false;
            AboveAverage  = true;
            Percent       = false;
            Bottom        = false;
            Operator      = ConditionalFormattingOperatorValues.Equal;
            HasOperator   = false;
            Text          = null;
            TimePeriod    = TimePeriodValues.Today;
            HasTimePeriod = false;
            Rank          = null;
            StdDev        = null;
            EqualAverage  = false;
        }
예제 #2
0
        internal SLDataBar Clone()
        {
            var db = new SLDataBar();

            db.Is2010                               = Is2010;
            db.MinimumType                          = MinimumType;
            db.MinimumValue                         = MinimumValue;
            db.MaximumType                          = MaximumType;
            db.MaximumValue                         = MaximumValue;
            db.Color                                = Color.Clone();
            db.BorderColor                          = BorderColor.Clone();
            db.NegativeFillColor                    = NegativeFillColor.Clone();
            db.NegativeBorderColor                  = NegativeBorderColor.Clone();
            db.AxisColor                            = AxisColor.Clone();
            db.MinLength                            = MinLength;
            db.MaxLength                            = MaxLength;
            db.ShowValue                            = ShowValue;
            db.Border                               = Border;
            db.Gradient                             = Gradient;
            db.Direction                            = Direction;
            db.NegativeBarColorSameAsPositive       = NegativeBarColorSameAsPositive;
            db.NegativeBarBorderColorSameAsPositive = NegativeBarBorderColorSameAsPositive;
            db.AxisPosition                         = AxisPosition;

            return(db);
        }
        internal void FromConditionalFormattingRule(ConditionalFormattingRule cfr)
        {
            SetAllNull();

            if (cfr.Type != null)
            {
                Type = cfr.Type.Value;
            }
            if (cfr.FormatId != null)
            {
                FormatId = cfr.FormatId.Value;
            }
            Priority = cfr.Priority.Value;
            if (cfr.StopIfTrue != null)
            {
                StopIfTrue = cfr.StopIfTrue.Value;
            }
            if (cfr.AboveAverage != null)
            {
                AboveAverage = cfr.AboveAverage.Value;
            }
            if (cfr.Percent != null)
            {
                Percent = cfr.Percent.Value;
            }
            if (cfr.Bottom != null)
            {
                Bottom = cfr.Bottom.Value;
            }
            if (cfr.Operator != null)
            {
                Operator    = cfr.Operator.Value;
                HasOperator = true;
            }
            if (cfr.Text != null)
            {
                Text = cfr.Text.Value;
            }
            if (cfr.TimePeriod != null)
            {
                TimePeriod    = cfr.TimePeriod.Value;
                HasTimePeriod = true;
            }
            if (cfr.Rank != null)
            {
                Rank = cfr.Rank.Value;
            }
            if (cfr.StdDev != null)
            {
                StdDev = cfr.StdDev.Value;
            }
            if (cfr.EqualAverage != null)
            {
                EqualAverage = cfr.EqualAverage.Value;
            }

            using (var oxr = OpenXmlReader.Create(cfr))
            {
                while (oxr.Read())
                {
                    if (oxr.ElementType == typeof(Formula))
                    {
                        Formulas.Add((Formula)oxr.LoadCurrentElement().CloneNode(true));
                    }
                    else if (oxr.ElementType == typeof(ColorScale))
                    {
                        ColorScale = new SLColorScale();
                        ColorScale.FromColorScale((ColorScale)oxr.LoadCurrentElement());
                        HasColorScale = true;
                    }
                    else if (oxr.ElementType == typeof(DataBar))
                    {
                        DataBar = new SLDataBar();
                        DataBar.FromDataBar((DataBar)oxr.LoadCurrentElement());
                        HasDataBar = true;
                    }
                    else if (oxr.ElementType == typeof(IconSet))
                    {
                        IconSet = new SLIconSet();
                        IconSet.FromIconSet((IconSet)oxr.LoadCurrentElement());
                        HasIconSet = true;
                    }
                    else if (oxr.ElementType == typeof(ConditionalFormattingRuleExtension))
                    {
                        Extensions.Add((ConditionalFormattingRuleExtension)oxr.LoadCurrentElement().CloneNode(true));
                    }
                }
            }
        }