예제 #1
0
        internal void FromDataBar(DataBar db)
        {
            SetAllNull();

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

            if (db.MinLength != null)
            {
                MinLength = db.MinLength.Value;
            }
            if (db.MaxLength != null)
            {
                MaxLength = db.MaxLength.Value;
            }
            if (db.ShowValue != null)
            {
                ShowValue = db.ShowValue.Value;
            }
        }
예제 #2
0
        internal DataBar ToDataBar()
        {
            var db = new DataBar();

            if (MinLength != 10)
            {
                db.MinLength = MinLength;
            }
            if (MaxLength != 90)
            {
                db.MaxLength = MaxLength;
            }
            if (!ShowValue)
            {
                db.ShowValue = ShowValue;
            }

            SLConditionalFormatValueObject cfvo;

            cfvo      = new SLConditionalFormatValueObject();
            cfvo.Type = ConditionalFormatValueObjectValues.Min;
            switch (MinimumType)
            {
            case SLConditionalFormatAutoMinMaxValues.Automatic:
                cfvo.Type = ConditionalFormatValueObjectValues.Min;
                cfvo.Val  = string.Empty;
                break;

            case SLConditionalFormatAutoMinMaxValues.Formula:
                cfvo.Type = ConditionalFormatValueObjectValues.Formula;
                cfvo.Val  = MinimumValue;
                break;

            case SLConditionalFormatAutoMinMaxValues.Number:
                cfvo.Type = ConditionalFormatValueObjectValues.Number;
                cfvo.Val  = MinimumValue;
                break;

            case SLConditionalFormatAutoMinMaxValues.Percent:
                cfvo.Type = ConditionalFormatValueObjectValues.Percent;
                cfvo.Val  = MinimumValue;
                break;

            case SLConditionalFormatAutoMinMaxValues.Percentile:
                cfvo.Type = ConditionalFormatValueObjectValues.Percentile;
                cfvo.Val  = 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 (MaximumType)
            {
            case SLConditionalFormatAutoMinMaxValues.Automatic:
                cfvo.Type = ConditionalFormatValueObjectValues.Max;
                cfvo.Val  = string.Empty;
                break;

            case SLConditionalFormatAutoMinMaxValues.Formula:
                cfvo.Type = ConditionalFormatValueObjectValues.Formula;
                cfvo.Val  = MaximumValue;
                break;

            case SLConditionalFormatAutoMinMaxValues.Number:
                cfvo.Type = ConditionalFormatValueObjectValues.Number;
                cfvo.Val  = MaximumValue;
                break;

            case SLConditionalFormatAutoMinMaxValues.Percent:
                cfvo.Type = ConditionalFormatValueObjectValues.Percent;
                cfvo.Val  = MaximumValue;
                break;

            case SLConditionalFormatAutoMinMaxValues.Percentile:
                cfvo.Type = ConditionalFormatValueObjectValues.Percentile;
                cfvo.Val  = MaximumValue;
                break;

            case SLConditionalFormatAutoMinMaxValues.Value:
                cfvo.Type = ConditionalFormatValueObjectValues.Max;
                cfvo.Val  = string.Empty;
                break;
            }
            db.Append(cfvo.ToConditionalFormatValueObject());

            db.Append(Color.ToSpreadsheetColor());

            return(db);
        }