private static object GetDataValueByBookmark(DefinedName bookmark, SOARolePropertyRow row)
        {
            object result = null;

            SOARolePropertyValue propertyValue = row.Values.FindByColumnName(bookmark.Name);

            if (propertyValue != null)
            {
                if (propertyValue.Column.DataType != ColumnDataType.String)
                    result = DataConverter.ChangeType(typeof(string), propertyValue.Value, propertyValue.Column.RealDataType);
                else
                    result = propertyValue.Value;
            }
            else
            {
                switch (bookmark.Name.ToLower())
                {
                    case "operatortype":
                        result = row.OperatorType.ToString();
                        break;
                    case "operator":
                        result = row.Operator;
                        break;
                }
            }

            return result;
        }
Beispiel #2
0
        /// <summary>
        /// FileName:workbook.xml 
        /// <para>NodePath:workbook/definedNames</para>
        /// </summary>
        /// <param name="definedNamesRoot"></param>
        internal void ReadWorkBook_definedNames(XElement definedNamesRoot, ExcelLoadContext context)
        {
            if (definedNamesRoot != null)
            {
                foreach (XElement item in definedNamesRoot.Nodes())
                {
                    Match rangeMatch = DefinedName.NameRangeReferenceRegex.Match(item.Value);
                    if (rangeMatch.Success)
                    {
                        if (rangeMatch.Groups["Sheet"].Success)
                        {
                            string sheetName = rangeMatch.Groups["Sheet"].Value;
                            if (sheetName.IsNotEmpty())
                            {
                                WorkSheet currentSheet = this.WorkBook.Sheets[sheetName];

                                DefinedName namedRange = new DefinedName(item.Attribute("name").Value, currentSheet)
                                {
                                    Address = Range.Parse(currentSheet, rangeMatch.Groups["Range"].Value),
                                    NameComment = item.Attribute("comment") == null ? string.Empty : item.Attribute("comment").Value,
                                    IsNameHidden = item.Attribute("hidden") == null ? false : (int.Parse(item.Attribute("hidden").Value) == 1 ? true : false),
                                };
                                if (item.Attribute("localSheetId") != null)
                                {
                                    int localsheetID;
                                    if (int.TryParse(item.Attribute("localSheetId").Value, out localsheetID))
                                        namedRange.LocalSheetId = localsheetID;
                                }

                                context.DefinedNames.Add(namedRange);
                            }
                        }

                        //todo: pivottable 
                        // if (rangeMatch.Groups["Table"].Success)

                    }

                    /*	DefinedName namedRange = new DefinedName(item.Attributes("name"),) 
                        { 
                            Address = item.Value
                        };

                       item.Attributes("name")
                        foreach (XAttribute attr in item.Attributes())
                        {
                            switch (attr.Name.LocalName)
                            {
                                case "name":
                                    namedRange.Name = attr.Value;
                                    break;
                                case "comment":
                                    namedRange.NameComment = attr.Value;
                                    break;
                                case "localSheetId":
                                    namedRange.LocalSheetId = int.Parse(attr.Value);
                                    break;
                                case "hidden":
                                    namedRange.IsNameHidden = int.Parse(attr.Value) == 1 ? true : false;
                                    break;
                            }
                        }
                       this.WorkBook.Names.Add(namedRange);*/
                }
            }
        }