示例#1
0
        void Application_SheetBeforeDelete(object sh)
        {
            var ws = sh as Excel.Worksheet;
            var wb = ws.Parent as Excel.Workbook;

            OnWorksheetBeforeDelete(new WorksheetBeforeDeleteEventArgs(ws.Name, wb.Name, ws));
            PendingRequest = new CloseRequestInfo(ws.Name, wb.Name, wb.Worksheets.Count);
        }
示例#2
0
        void Application_SheetDeactivate(object sh)
        {
            var ws = sh as Excel.Worksheet;
            var wb = ws.Parent as Excel.Workbook;

            if (wb.Worksheets.Count == 1)
            {
                // With only one workbook available deactivating means it will be closed
                PendingRequest = null;
                OnWorksheetDeleted(new WorksheetDeletedEventArgs(ws.Name, wb.Name));
            }
        }
示例#3
0
        void Application_SheetActivate(object sh)
        {
            var ws = sh as Excel.Worksheet;
            var wb = ws.Parent as Excel.Workbook;

            // A worksheet was closed if a request is pending and the worksheet count decreased
            var wasClosed = PendingRequest != null && wb.Worksheets.Count < PendingRequest.WorksheetCount;

            if (wasClosed)
            {
                var args = new WorksheetDeletedEventArgs(PendingRequest.WorksheetName, PendingRequest.WorkbookName);
                PendingRequest = null;
                OnWorksheetDeleted(args);
            }
            else
            {
                PendingRequest = null;
            }
        }