private void Workbook_SheetDeactivate(object Sh) { if (ActiveSheet == null) { return; } ActiveSheet.Dispose(); ActiveSheet = null; }
/// <summary> /// Create the controller while passing the Workbook to work on. /// </summary> /// <param name="workbook">Workbook to work on</param> public ExcelWorkbookController(Excel.Workbook workbook) { Workbook = workbook; // Add ActiveSheet controller ActiveSheet = new ExcelSheetController(Workbook.ActiveSheet); // Add event handlers Workbook.SheetActivate += Workbook_SheetActivate; Workbook.SheetDeactivate += Workbook_SheetDeactivate; }
private void Workbook_SheetActivate(object Sh) { ActiveSheet = new ExcelSheetController((Excel.Worksheet)Sh); }