コード例 #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;
            }
        }