Beispiel #1
0
        public static void Main(string[] args)
        {
            Excel.Application app = null;
            try
            {
                System.Console.WriteLine("NetOffice CreateInstance Event Concept Test\r\n");

                // Use this.Factory.CreateInstance instead in NetOffice Tools COMAddin
                NetOffice.Core.Default.CreateInstance += new Core.OnCreateInstanceEventHandler(Default_CreateInstance);
                //Disable NO console for clean view/output
                NetOffice.Core.Default.Console.Mode = DebugConsoleMode.None;

                app = new Excel.Application();
                Excel.Workbook    book  = app.Workbooks.Add();
                MyCustomWorksheet sheet = book.Sheets[1] as MyCustomWorksheet;
                sheet.PrintName();

                Console.WriteLine("\r\nTest passed");
                Console.ReadKey();
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
                Console.ReadKey();
            }
            finally
            {
                if (null != app)
                {
                    app.Quit();
                    app.Dispose();
                    app = null;
                }
            }
        }
Beispiel #2
0
        public static void Main(string[] args)
        {
            Excel.Application app = null;
            try
            {
                System.Console.WriteLine("NetOffice CreateInstance Event Concept Test\r\n");

                // Use this.Factory.CreateInstance instead in NetOffice Tools COMAddin
                NetOffice.Core.Default.ObjectActivator.CreateInstance += ObjectActivator_CreateInstance;

                app = new Excel.ApplicationClass();
                Excel.Workbook    book  = app.Workbooks.Add();
                MyCustomWorksheet sheet = book.Sheets[1] as MyCustomWorksheet;
                sheet.PrintName();

                Console.WriteLine("\r\nTest passed");
                Console.ReadKey();
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
                Console.ReadKey();
            }
            finally
            {
                if (null != app)
                {
                    app.Quit();
                    app.Dispose();
                    app = null;
                }
            }
        }