コード例 #1
0
        /// <summary>
        /// Creates a basic SealExcelConverter
        /// </summary>
        public static SealExcelConverter Create(string assemblyDirectory)
        {
            SealExcelConverter result = null;
            //Check if an implementation is available in a .dll
            string applicationPath = string.IsNullOrEmpty(assemblyDirectory) ? Path.GetDirectoryName(Application.ExecutablePath) : assemblyDirectory;

            if (File.Exists(Path.Combine(applicationPath, "SealConverter.dll")))
            {
                try
                {
                    Assembly currentAssembly = AppDomain.CurrentDomain.Load("SealConverter");
                    Type     t    = currentAssembly.GetType("SealExcelConverter.ExcelConverter", true);
                    Object[] args = new Object[] { };
                    result = (SealExcelConverter)t.InvokeMember(null, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance | BindingFlags.CreateInstance, null, null, args);
                    result.ApplicationPath = applicationPath;
                    //Load related DLLs
                    Assembly.LoadFrom(Path.Combine(applicationPath, "DocumentFormat.OpenXml.dll"));
                    Assembly.LoadFrom(Path.Combine(applicationPath, "EPPlus.dll"));
                }
                catch { }
            }

            if (result == null)
            {
                result = new SealExcelConverter();
            }

            return(result);
        }
コード例 #2
0
        /// <summary>
        /// Creates a basic SealExcelConverter
        /// </summary>
        public static SealExcelConverter Create()
        {
            SealExcelConverter result = null;

            //Check if an implementation is available in a .dll
            if (File.Exists(Repository.Instance.SealConverterPath))
            {
                try
                {
                    Assembly currentAssembly = Assembly.LoadFrom(Repository.Instance.SealConverterPath);
                    Type     t    = currentAssembly.GetType("Seal.Converter.ExcelConverter", true);
                    object[] args = new object[] { };
                    result = (SealExcelConverter)t.InvokeMember(null, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance | BindingFlags.CreateInstance, null, null, args);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            if (result == null)
            {
                result = new SealExcelConverter();
            }

            return(result);
        }
コード例 #3
0
        public static SealExcelConverter Create(string assemblyDirectory)
        {
            SealExcelConverter result = null;
            //Check if an implementation is available in a .dll
            string applicationPath = string.IsNullOrEmpty(assemblyDirectory) ? Path.GetDirectoryName(Application.ExecutablePath) : assemblyDirectory;
            if (File.Exists(Path.Combine(applicationPath, "SealConverter.dll")))
            {
                try
                {
                    Assembly currentAssembly = AppDomain.CurrentDomain.Load("SealConverter");
                    Type t = currentAssembly.GetType("SealExcelConverter.ExcelConverter", true);
                    Object[] args = new Object[] { };
                    result = (SealExcelConverter)t.InvokeMember(null, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance | BindingFlags.CreateInstance, null, null, args);
                    result.ApplicationPath = applicationPath;
                }
                catch { }
            }

            if (result == null) result = new SealExcelConverter();
            
            return result;
        }