internal void Run() { MyCore core = new MyCore(); core.ObjectActivator.RegisterType(typeof(Excel.Application), typeof(MyExcelApplication)); core.ObjectActivator.RegisterType(typeof(Excel.Range), typeof(MyExcelRange)); core.Settings.EnableAutomaticQuit = true; using (Excel.Application application = COMObject.Create <Excel.Application>(core)) { application.DisplayAlerts = false; var workbooks = application.Workbooks; var book = workbooks.Add(); var sheet = book.Sheets.Add().To <Excel.Worksheet>(); bool visible = application.Visible; application.Visible = true; try { application.Visible = false; } catch (ArgumentException) { Console.WriteLine("MyExcelApplication prevent us to make excel invisible."); } var range = sheet.Range("$A1"); range.Value = null; var value = range.Value; Console.WriteLine("We set null for range but MyExcelRange change it to {0}.", value); } }
internal void Run() { MyCore core = new MyCore(); core.Settings.EnableAutomaticQuit = true; core.Settings.ForceApplicationVersionProviders = true; using (Excel.Application application = new Excel.ApplicationClass(core)) { application.DisplayAlerts = false; var workbooks = application.Workbooks; var book = workbooks.Add(); var sheet = book.Sheets.Add() as Excel.Worksheet; try { sheet.Range("NONSENS").Value = "value"; } catch (NetOfficeCOMException exception) { Console.WriteLine("NetOfficeCOMException, NetOffice Version:{0} Application Version:{1}", exception.NetOfficeVersion, exception.ApplicationVersion); } catch (Exception exception) { Console.WriteLine("Unexpected Exception {0}", exception); } } }
internal void Run() { MyCore core = new MyCore(); core.Settings.EnableAutomaticQuit = true; using (Excel.Application application = new Excel.ApplicationClass(core)) { application.WorkbookActivateEvent += Application_WorkbookActivateEvent; application.DisplayAlerts = false; var book = application.Workbooks.Add(); var sheet = book.Sheets.Add() as Excel.Worksheet; } }
internal void Run() { MyCore core = new MyCore(); core.Settings.EnableAutomaticQuit = true; using (Excel.Application application = new Excel.ApplicationClass(core)) { application.DisplayAlerts = false; var workbooks = application.Workbooks; var book = workbooks.Add(); book.Sheets.Add(); Console.WriteLine("Living Objects {0}", core.ObjectRegister.Count); } Console.WriteLine("Living Objects {0}", core.ObjectRegister.Count); }
internal void Run() { MyCore core = new MyCore(); core.Settings.EnableAutomaticQuit = true; using (Excel.Application application = new Excel.ApplicationClass(core)) { application.DisplayAlerts = false; var workbooks = application.Workbooks; var book = workbooks.Add(); book.Sheets.Add(); string instanceFriendlyName = application.InstanceFriendlyName; string instanceComponentName = application.InstanceComponentName; Console.WriteLine("InstanceFriendlyName:{0}", instanceFriendlyName); Console.WriteLine("InstanceComponentName:{0}", instanceComponentName); } }
internal void Run() { MyCore core = new MyCore(); core.Settings.EnableAutomaticQuit = true; using (Excel.Application application = new Excel.ApplicationClass(core)) { application.DisplayAlerts = false; var workbooks = application.Workbooks; var book = workbooks.Add(); book.Sheets.Add(); } var typeCache = core.Cache.GetTypeCache(); Console.WriteLine("--Start Type Cache Log--"); foreach (var item in typeCache) { Console.WriteLine("Cache Item Factory:{0}\r\nComponent:{1}\r\nType:{2}\r\nContract:{3}\r\nImplementation:{4}\r\n", item.Factory.FactoryName, item.ComponentId, item.TypeId, item.Contract.FullName, item.Implementation.FullName); } Console.WriteLine("--End Type Cache Log--"); }