Пример #1
0
        public static string mmModifyObj(string objName, string objType, string key, object value)
        {
            ExcelObject obj = ObjectHandler.GetObject(objName, objType);

            if (obj == null)
            {
                return("Object not found.");
            }
            FieldInfo[] keyList = obj.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
            foreach (var keyL in keyList)
            {
                if (key.ToUpper() == keyL.Name.ToUpper())
                {
                    try
                    {
                        keyL.SetValue(obj, value);
                        return(obj.FinishMod().GetNameCounter());
                    }
                    catch (Exception e)
                    {
                        return(e.Message);
                    }
                }
            }
            return("Object found, key not found.");
        }
Пример #2
0
        public static object[,] mmGetObjInfo(string objName, string objType, string key, object column, object row)
        {
            ExcelObject obj = ObjectHandler.GetObject(objName, objType);

            if (obj == null)
            {
                return new object[, ] {
                           { "Object not found." }
                }
            }
            ;
            FieldInfo[] keyList = obj.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
            foreach (var keyL in keyList)
            {
                if (key.ToUpper() == keyL.Name.ToUpper())
                {
                    try
                    {
                        if (typeof(IIMatrix).IsAssignableFrom(keyL.FieldType))
                        {
                            return(((IIMatrix)keyL.GetValue(obj)).ObjInfo(column, row));
                        }
                        return(new object[, ] {
                            { keyL.GetValue(obj).ToString() }
                        });
                    }
                    catch (Exception e)
                    {
                        return(new object[, ] {
                            { e.Message }
                        });
                    }
                }
            }
            return(new object[, ] {
                { "Object found, key not found." }
            });
        }