Exemplo n.º 1
0
        internal DataBar ToDataBar()
        {
            DataBar db = new DataBar();
            if (this.MinLength != 10) db.MinLength = this.MinLength;
            if (this.MaxLength != 90) db.MaxLength = this.MaxLength;
            if (!this.ShowValue) db.ShowValue = this.ShowValue;

            SLConditionalFormatValueObject cfvo;

            cfvo = new SLConditionalFormatValueObject();
            cfvo.Type = ConditionalFormatValueObjectValues.Min;
            switch (this.MinimumType)
            {
                case SLConditionalFormatAutoMinMaxValues.Automatic:
                    cfvo.Type = ConditionalFormatValueObjectValues.Min;
                    cfvo.Val = string.Empty;
                    break;
                case SLConditionalFormatAutoMinMaxValues.Formula:
                    cfvo.Type = ConditionalFormatValueObjectValues.Formula;
                    cfvo.Val = this.MinimumValue;
                    break;
                case SLConditionalFormatAutoMinMaxValues.Number:
                    cfvo.Type = ConditionalFormatValueObjectValues.Number;
                    cfvo.Val = this.MinimumValue;
                    break;
                case SLConditionalFormatAutoMinMaxValues.Percent:
                    cfvo.Type = ConditionalFormatValueObjectValues.Percent;
                    cfvo.Val = this.MinimumValue;
                    break;
                case SLConditionalFormatAutoMinMaxValues.Percentile:
                    cfvo.Type = ConditionalFormatValueObjectValues.Percentile;
                    cfvo.Val = this.MinimumValue;
                    break;
                case SLConditionalFormatAutoMinMaxValues.Value:
                    cfvo.Type = ConditionalFormatValueObjectValues.Min;
                    cfvo.Val = string.Empty;
                    break;
            }
            db.Append(cfvo.ToConditionalFormatValueObject());

            cfvo = new SLConditionalFormatValueObject();
            cfvo.Type = ConditionalFormatValueObjectValues.Max;
            switch (this.MaximumType)
            {
                case SLConditionalFormatAutoMinMaxValues.Automatic:
                    cfvo.Type = ConditionalFormatValueObjectValues.Max;
                    cfvo.Val = string.Empty;
                    break;
                case SLConditionalFormatAutoMinMaxValues.Formula:
                    cfvo.Type = ConditionalFormatValueObjectValues.Formula;
                    cfvo.Val = this.MaximumValue;
                    break;
                case SLConditionalFormatAutoMinMaxValues.Number:
                    cfvo.Type = ConditionalFormatValueObjectValues.Number;
                    cfvo.Val = this.MaximumValue;
                    break;
                case SLConditionalFormatAutoMinMaxValues.Percent:
                    cfvo.Type = ConditionalFormatValueObjectValues.Percent;
                    cfvo.Val = this.MaximumValue;
                    break;
                case SLConditionalFormatAutoMinMaxValues.Percentile:
                    cfvo.Type = ConditionalFormatValueObjectValues.Percentile;
                    cfvo.Val = this.MaximumValue;
                    break;
                case SLConditionalFormatAutoMinMaxValues.Value:
                    cfvo.Type = ConditionalFormatValueObjectValues.Max;
                    cfvo.Val = string.Empty;
                    break;
            }
            db.Append(cfvo.ToConditionalFormatValueObject());

            db.Append(this.Color.ToSpreadsheetColor());

            return db;
        }
Exemplo n.º 2
0
        internal void FromDataBar(DataBar db)
        {
            this.SetAllNull();

            using (OpenXmlReader oxr = OpenXmlReader.Create(db))
            {
                int i = 0;
                SLConditionalFormatValueObject cfvo;
                while (oxr.Read())
                {
                    if (oxr.ElementType == typeof(ConditionalFormatValueObject))
                    {
                        if (i == 0)
                        {
                            cfvo = new SLConditionalFormatValueObject();
                            cfvo.FromConditionalFormatValueObject((ConditionalFormatValueObject)oxr.LoadCurrentElement());
                            this.MinimumType = this.TranslateToAutoMinMaxValues(cfvo.Type);
                            this.MinimumValue = cfvo.Val;
                            ++i;
                        }
                        else if (i == 1)
                        {
                            cfvo = new SLConditionalFormatValueObject();
                            cfvo.FromConditionalFormatValueObject((ConditionalFormatValueObject)oxr.LoadCurrentElement());
                            this.MaximumType = this.TranslateToAutoMinMaxValues(cfvo.Type);
                            this.MaximumValue = cfvo.Val;
                            ++i;
                        }
                    }
                    else if (oxr.ElementType == typeof(Color))
                    {
                        this.Color.FromSpreadsheetColor((Color)oxr.LoadCurrentElement());
                    }
                }
            }

            if (db.MinLength != null) this.MinLength = db.MinLength.Value;
            if (db.MaxLength != null) this.MaxLength = db.MaxLength.Value;
            if (db.ShowValue != null) this.ShowValue = db.ShowValue.Value;
        }
Exemplo n.º 3
0
        internal void FromDataBar(X14.DataBar db)
        {
            this.SetAllNull();

            using (OpenXmlReader oxr = OpenXmlReader.Create(db))
            {
                int i = 0;
                while (oxr.Read())
                {
                    if (oxr.ElementType == typeof(X14.ConditionalFormattingValueObject))
                    {
                        if (i == 0)
                        {
                            this.Cfvo1.FromConditionalFormattingValueObject((X14.ConditionalFormattingValueObject)oxr.LoadCurrentElement());
                            ++i;
                        }
                        else if (i == 1)
                        {
                            this.Cfvo2.FromConditionalFormattingValueObject((X14.ConditionalFormattingValueObject)oxr.LoadCurrentElement());
                            ++i;
                        }
                    }
                    else if (oxr.ElementType == typeof(X14.FillColor))
                    {
                        this.FillColor.FromFillColor((X14.FillColor)oxr.LoadCurrentElement());
                    }
                    else if (oxr.ElementType == typeof(X14.BorderColor))
                    {
                        this.BorderColor.FromBorderColor((X14.BorderColor)oxr.LoadCurrentElement());
                    }
                    else if (oxr.ElementType == typeof(X14.NegativeFillColor))
                    {
                        this.NegativeFillColor.FromNegativeFillColor((X14.NegativeFillColor)oxr.LoadCurrentElement());
                    }
                    else if (oxr.ElementType == typeof(X14.NegativeBorderColor))
                    {
                        this.NegativeBorderColor.FromNegativeBorderColor((X14.NegativeBorderColor)oxr.LoadCurrentElement());
                    }
                    else if (oxr.ElementType == typeof(X14.BarAxisColor))
                    {
                        this.AxisColor.FromBarAxisColor((X14.BarAxisColor)oxr.LoadCurrentElement());
                    }
                }
            }

            if (db.MinLength != null)
            {
                this.MinLength = db.MinLength.Value;
            }
            if (db.MaxLength != null)
            {
                this.MaxLength = db.MaxLength.Value;
            }
            if (db.ShowValue != null)
            {
                this.ShowValue = db.ShowValue.Value;
            }
            if (db.Border != null)
            {
                this.Border = db.Border.Value;
            }
            if (db.Gradient != null)
            {
                this.Gradient = db.Gradient.Value;
            }
            if (db.Direction != null)
            {
                this.Direction = db.Direction.Value;
            }
            if (db.NegativeBarColorSameAsPositive != null)
            {
                this.NegativeBarColorSameAsPositive = db.NegativeBarColorSameAsPositive.Value;
            }
            if (db.NegativeBarBorderColorSameAsPositive != null)
            {
                this.NegativeBarBorderColorSameAsPositive = db.NegativeBarBorderColorSameAsPositive.Value;
            }
            if (db.AxisPosition != null)
            {
                this.AxisPosition = db.AxisPosition.Value;
            }
        }
Exemplo n.º 4
0
        internal X14.DataBar ToDataBar(bool RenderFillColor)
        {
            X14.DataBar db = new X14.DataBar();
            if (this.MinLength != 10) db.MinLength = this.MinLength;

            // according to Open XML specs, this cannot be more than 100 percent.
            if (this.MaxLength > 100) this.MaxLength = 100;
            if (this.MaxLength != 90) db.MaxLength = this.MaxLength;

            if (!this.ShowValue) db.ShowValue = this.ShowValue;
            if (this.Border) db.Border = this.Border;
            if (!this.Gradient) db.Gradient = this.Gradient;
            if (this.Direction != X14.DataBarDirectionValues.Context) db.Direction = this.Direction;
            if (this.NegativeBarColorSameAsPositive) db.NegativeBarColorSameAsPositive = this.NegativeBarColorSameAsPositive;
            if (!this.NegativeBarBorderColorSameAsPositive) db.NegativeBarBorderColorSameAsPositive = this.NegativeBarBorderColorSameAsPositive;
            if (this.AxisPosition != X14.DataBarAxisPositionValues.Automatic) db.AxisPosition = this.AxisPosition;

            db.Append(this.Cfvo1.ToConditionalFormattingValueObject());
            db.Append(this.Cfvo2.ToConditionalFormattingValueObject());

            // The condition is mainly if the priority of the parent rule exists. See Open XML specs.
            if (RenderFillColor) db.Append(this.FillColor.ToFillColor());

            if (this.Border) db.Append(this.BorderColor.ToBorderColor());
            if (!this.NegativeBarColorSameAsPositive) db.Append(this.NegativeFillColor.ToNegativeFillColor());
            if (!this.NegativeBarBorderColorSameAsPositive && this.Border) db.Append(this.NegativeBorderColor.ToNegativeBorderColor());
            if (this.AxisPosition != X14.DataBarAxisPositionValues.None) db.Append(this.AxisColor.ToBarAxisColor());

            return db;
        }
Exemplo n.º 5
0
        internal X14.DataBar ToDataBar(bool RenderFillColor)
        {
            X14.DataBar db = new X14.DataBar();
            if (this.MinLength != 10)
            {
                db.MinLength = this.MinLength;
            }

            // according to Open XML specs, this cannot be more than 100 percent.
            if (this.MaxLength > 100)
            {
                this.MaxLength = 100;
            }
            if (this.MaxLength != 90)
            {
                db.MaxLength = this.MaxLength;
            }

            if (!this.ShowValue)
            {
                db.ShowValue = this.ShowValue;
            }
            if (this.Border)
            {
                db.Border = this.Border;
            }
            if (!this.Gradient)
            {
                db.Gradient = this.Gradient;
            }
            if (this.Direction != X14.DataBarDirectionValues.Context)
            {
                db.Direction = this.Direction;
            }
            if (this.NegativeBarColorSameAsPositive)
            {
                db.NegativeBarColorSameAsPositive = this.NegativeBarColorSameAsPositive;
            }
            if (!this.NegativeBarBorderColorSameAsPositive)
            {
                db.NegativeBarBorderColorSameAsPositive = this.NegativeBarBorderColorSameAsPositive;
            }
            if (this.AxisPosition != X14.DataBarAxisPositionValues.Automatic)
            {
                db.AxisPosition = this.AxisPosition;
            }

            db.Append(this.Cfvo1.ToConditionalFormattingValueObject());
            db.Append(this.Cfvo2.ToConditionalFormattingValueObject());

            // The condition is mainly if the priority of the parent rule exists. See Open XML specs.
            if (RenderFillColor)
            {
                db.Append(this.FillColor.ToFillColor());
            }

            if (this.Border)
            {
                db.Append(this.BorderColor.ToBorderColor());
            }
            if (!this.NegativeBarColorSameAsPositive)
            {
                db.Append(this.NegativeFillColor.ToNegativeFillColor());
            }
            if (!this.NegativeBarBorderColorSameAsPositive && this.Border)
            {
                db.Append(this.NegativeBorderColor.ToNegativeBorderColor());
            }
            if (this.AxisPosition != X14.DataBarAxisPositionValues.None)
            {
                db.Append(this.AxisColor.ToBarAxisColor());
            }

            return(db);
        }