SheetXL - v0.8.0-beta.9+sites.210.e2d420901
    Preparing search index...

    Interface IProtectedRange

    A named range (or set of ranges) that stays editable while the sheet as a whole is protected.

    Excel surfaces these as Review → Allow Edit Ranges, and OOXML persists them as <protectedRange> inside <protectedRanges>. Despite the name, a protected range relaxes protection rather than adding it: it is only consulted while ISheetProtection.isLocked is true, and it grants an exemption for the cells it covers — optionally behind a password.

    • Like IConditionalFormat and IDataValidation, one entry may be anchored to several discontiguous ranges (sqref="A1:B4 D1:D9"), and any single range can become several when a row/column delete splits it.
    • getName is required and unique within the sheet.
    interface IProtectedRange {
        isIAnchored: true;
        isIProtectedRange: true;
        addListeners(
            listeners: IProtectedRange.IListeners,
            options?: IListener.Options,
        ): Remove;
        checkPassword(password?: string): Promise<boolean>;
        close(): void;
        delete(): void;
        getAnchorType?(): IAnchored.Type;
        getEncryptedPassword(): Readonly<Partial<EncryptedPassword>> | null;
        getIndex(): number;
        getName(): string;
        getRanges(options?: ICellRange.GetRangeOptions): ICellRanges;
        getSecurityDescriptor(): string | null;
        hasPassword(): boolean;
        isClosed(): boolean;
        isDeleted(): boolean;
        isProtected(): boolean;
        isUnlocked(): boolean;
        relock(): this;
        setIndex(index: number): this;
        setName(name: string, options?: ITransaction.OperationOptions): this;
        setPassword(
            password: string | null,
            options?: SetPasswordOptions,
        ): Promise<IProtectedRange>;
        setRanges(
            address: ICellRanges.Address,
            options?: ITransaction.OperationOptions,
        ): this;
        setSecurityDescriptor(
            descriptor: string | null,
            options?: ITransaction.OperationOptions,
        ): this;
        toJSON(): IProtectedRange.JSON | null;
        unlock(password?: string): Promise<boolean>;
        update(
            properties: IProtectedRange | Partial<IProtectedRange.Properties>,
            options?: ITransaction.OperationOptions,
        ): this;
    }

    Hierarchy (View Summary)

    Index
    isIAnchored: true

    For runtime type checking.

    isIProtectedRange: true

    For runtime type checking.

    • Verifies a plain-text password against the stored hash.

      Parameters

      • Optionalpassword: string

        The password to check.

      Returns Promise<boolean>

      true when it matches, or when no password is set. false otherwise.

      Never throws for a wrong password — unlike IProtection.checkPassword, which is a gate. This is a predicate.

    • Similar to delete but cleans resources and can't be undone.

      Returns void

    • Deletes the anchored item.

      Returns void

    • The stored password hash, or null if there is none.

      Returns Readonly<Partial<EncryptedPassword>> | null

      For persistence. The plain text is not recoverable from this.

    • Returns the index of this entry within its container.

      Returns number

      Unlike IConditionalFormat.getIndex this carries no evaluation semantics — protected ranges are an unordered set in OOXML. The index exists so the UI can present a stable list.

    • The unique name for this entry.

      Returns string

      Required by OOXML and unique within the sheet, but unrelated to the ranges it covers — it is a label, not a defined name, and never resolves as a reference.

    • Returns the ranges this object is anchored to, in authored order.

      Parameters

      Returns ICellRanges

      • Never null. An item whose last range was removed by a row/column delete returns an invalid ranges — ask ICellRanges.isInvalid, the same contract as ITable.getDataRange.
      • This is the general accessor. Most anchored types hold exactly one range and declare their own getRange() for it, but data validations, conditional formats and protected ranges are authored as several, and any single range can become several when a delete splits it.
    • The relative security descriptor, or null if there is none.

      Returns string | null

      Names the user accounts that may edit this range without supplying a password, e.g. "O:WDG:WDD:(A;;CC;;;AN)". SheetXL does not evaluate this — it is preserved for round-trip until the user identity system lands.

    • Returns true if a password must be supplied to edit this range.

      Returns boolean

    • Returns if the model has been closed

      Returns boolean

    • Returns if the model has been deleted

      Returns boolean

    • If the anchor is unable to be modified.

      Returns boolean

    • Whether edits to this range are currently permitted on a protected sheet.

      Returns boolean

      • true whenever there is no password — that is the whole point of an entry without one, and it needs no ceremony.
      • With a password, true only after unlock succeeded.

      Session state, not document state. It is never serialized, never recorded on the undo stack, and resets when the workbook is reopened — the same shape as IProtection.isPaused. This is what lets the write path consult it synchronously; a password check is async and cannot be awaited per cell.

      It lasts for one protection period: unprotecting the sheet revokes it (protecting again asks for the password afresh), while a IProtection.pause keeps it. Changing the password revokes it too.

    • Revokes a previous unlock.

      Returns this

      A no-op when there is no password, since such a range is always unlocked.

    • Sets (or clears) the password required to edit this range.

      Parameters

      Returns Promise<IProtectedRange>

      The password is hashed before it reaches the model state — the plain text is never stored and never serialized. Asynchronous because hashing is (PasswordHasher runs a spin count).

    • Re-anchors this protected range to address, REPLACING every range it currently covers.

      Parameters

      • address: ICellRanges.Address

        The range or ranges to cover — anything ISheet.getRanges accepts ('A1:C20', 'A1:A5, C1:C5', coords). Resolved against this protected range's own sheet.

      • Optionaloptions: ITransaction.OperationOptions

        Transaction options; description names the entry in undo history.

      Returns this

      A REPLACE, not an add: the ranges named become the whole anchor. An address that names nothing throws rather than leaving the protected range unanchored — clearing is IAnchored.delete.

      Undoable, and refused on a protected sheet. A protected range spans several ranges as readily as one; the OOXML sqref carries the whole list.

    • Grants edit access to this range for the rest of the session.

      Parameters

      • Optionalpassword: string

        The password, when one is set.

      Returns Promise<boolean>

      true when access was granted, false when the password did not match.

      Does not throw on a wrong password — callers are UI prompts that want to re-ask.