Search Results for

    Show / Hide Table of Contents

    ExcelFile.DeleteNamedRange Method

    Deletes the name at the specified position. Important: If the name you are trying to delete is referenced by any formula/chart/whatever in your file, the name will not actually be deleted but hidden.

    You won't see the name in Excel or in the formula, but it will be there and you can see it from FlexCel. You can use GetUsedNamedRanges to learn if a range might be deleted.

    Also, note that if you later delete the formulas that reference those ranges FlexCel will remove those hanging ranges when saving. The only hidden ranges that will be present in the final file will be those that have active formulas referencing them.

    Important:If the name wasn't deleted, NamedRangeCount will not change. This means that you can't have code like this:

        while (xls.NamedRangeCount > 0) //WRONG! This loop might never end.
        {
            xls.DeleteNamedRange(1);  //Might not be deleted, and NamedRangeCount will never be 0.
        }
    

    The correct code in this case would be:

        for (int i = xls.NamedRangeCount; i > 0; i--) xls.DeleteNamedRange(i);
    

    Syntax

    Namespace: FlexCel.Core

    public abstract void DeleteNamedRange(Int32 index)

    Parameters

    <-> Parameter Type Description
    index Int32 Index of the name to delete (1 based).

    See also

    • ExcelFile
    In This Article
    Back to top FlexCel Studio for the .NET Framework v7.24.0.0
    © 2002 - 2025 tmssoftware.com