Ejemplo n.º 1
0
        internal void FromIconSet(IconSet ics)
        {
            this.SetAllNull();

            if (ics.IconSetValue != null)
            {
                this.IconSetType = SLIconSet.TranslateIconSetToInternalSet(ics.IconSetValue.Value);
            }
            if (ics.ShowValue != null)
            {
                this.ShowValue = ics.ShowValue.Value;
            }
            if (ics.Percent != null)
            {
                this.Percent = ics.Percent.Value;
            }
            if (ics.Reverse != null)
            {
                this.Reverse = ics.Reverse.Value;
            }

            using (OpenXmlReader oxr = OpenXmlReader.Create(ics))
            {
                SLConditionalFormatValueObject cfvo;
                while (oxr.Read())
                {
                    if (oxr.ElementType == typeof(ConditionalFormatValueObject))
                    {
                        cfvo = new SLConditionalFormatValueObject();
                        cfvo.FromConditionalFormatValueObject((ConditionalFormatValueObject)oxr.LoadCurrentElement());
                        this.Cfvos.Add(cfvo);
                    }
                }
            }
        }
        internal void FromColorScale(ColorScale cs)
        {
            this.SetAllNull();

            SLConditionalFormatValueObject cfvo;
            SLColor clr;

            using (OpenXmlReader oxr = OpenXmlReader.Create(cs))
            {
                while (oxr.Read())
                {
                    if (oxr.ElementType == typeof(ConditionalFormatValueObject))
                    {
                        cfvo = new SLConditionalFormatValueObject();
                        cfvo.FromConditionalFormatValueObject((ConditionalFormatValueObject)oxr.LoadCurrentElement());
                        this.Cfvos.Add(cfvo);
                    }
                    else if (oxr.ElementType == typeof(Color))
                    {
                        clr = new SLColor(new List <System.Drawing.Color>(), new List <System.Drawing.Color>());
                        clr.FromSpreadsheetColor((Color)oxr.LoadCurrentElement());
                        this.Colors.Add(clr);
                    }
                }
            }
        }
        internal SLConditionalFormatValueObject Clone()
        {
            SLConditionalFormatValueObject cfvo = new SLConditionalFormatValueObject();

            cfvo.Type = this.Type;
            cfvo.Val  = this.Val;
            cfvo.GreaterThanOrEqual = this.GreaterThanOrEqual;

            return(cfvo);
        }
Ejemplo n.º 4
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;
            }
        }
Ejemplo n.º 5
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);
        }