NPOI.XSSF.UserModel.XSSFWorkbook.OnSheetDelete C# (CSharp) Метод

OnSheetDelete() приватный Метод

private OnSheetDelete ( int index ) : void
index int
Результат void
        private void OnSheetDelete(int index)
        {
            //delete the CT_Sheet reference from workbook.xml
            workbook.sheets.RemoveSheet(index);

            //calculation chain is auxiliary, remove it as it may contain orphan references to deleted cells
            if (calcChain != null)
            {
                RemoveRelation(calcChain);
                calcChain = null;
            }

            List<XSSFName> toRemoveNamedRanges=new List<XSSFName>();
            //adjust indices of names ranges
            foreach (XSSFName nm in namedRanges)
            {
                
                CT_DefinedName ct = nm.GetCTName();
                if (!ct.IsSetLocalSheetId()) continue;
                if (ct.localSheetId == index)
                {
                    toRemoveNamedRanges.Add(nm);
                }
                else if (ct.localSheetId > index)
                {
                    // Bump down by one, so still points at the same sheet
                    ct.localSheetId = (ct.localSheetId - 1);
                    ct.localSheetIdSpecified = true;
                }
            }
            foreach (XSSFName nm in toRemoveNamedRanges)
            {
                namedRanges.Remove(nm);
            }
        }