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

            this.Extensions = new List<ConditionalFormattingRuleExtension>();

            this.Type = ConditionalFormatValues.DataBar;

            this.DifferentialFormat = new SLDifferentialFormat();
            this.HasDifferentialFormat = false;

            this.FormatId = null;
            this.Priority = 1;
            this.StopIfTrue = false;
            this.AboveAverage = true;
            this.Percent = false;
            this.Bottom = false;
            this.Operator = ConditionalFormattingOperatorValues.Equal;
            this.HasOperator = false;
            this.Text = null;
            this.TimePeriod = TimePeriodValues.Today;
            this.HasTimePeriod = false;
            this.Rank = null;
            this.StdDev = null;
            this.EqualAverage = false;
        }
        internal void FromConditionalFormattingRule(ConditionalFormattingRule cfr)
        {
            this.SetAllNull();

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

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