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

    Interface IProtection<T, P, J>

    Interface representing the base protection functionality for both workbook and sheet protection. This interface provides methods for locking, unlocking, and managing the protection state.

    interface IProtection<
        T,
        P extends IProtection.Properties,
        J extends IProtection.JSON,
    > {
        isIProtection: true;
        addListeners(
            listeners: IProtection.IListeners,
            options?: IListener.Options,
        ): Remove;
        checkPassword(password?: string): Promise<boolean>;
        getProperties(): Partial<P> | null;
        hasPassword(): boolean;
        isLocked(): boolean;
        isPaused(): boolean;
        isReadOnly(): boolean;
        lock(
            properties?: Partial<P>,
            password?: string,
            algorithm?: string,
            spinCount?: number,
        ): Promise<IProtection<T, P, J>>;
        pause(password?: string): Promise<IProtection<T, P, J>>;
        resume(): IProtection<T, P, J>;
        setProperties(properties: Partial<P>): Promise<IProtection<T, P, J>>;
        toJSON(): IProtection.JSON | null;
        unlock(password?: string): Promise<IProtection<T, P, J>>;
    }

    Type Parameters

    Hierarchy (View Summary)

    Index
    isIProtection: true

    For runtime type checking.

    • Verifies if the provided password matches the current protection password.

      Parameters

      • Optionalpassword: string

        The password to check against the current protection.

      Returns Promise<boolean>

      true if the password is correct, false otherwise.

      Use this method to validate the password before unlocking or modifying the protection settings.

    • The object's options, kept while it is unlocked; null when it has none.

      Returns Partial<P> | null

      A property names what stays allowed while locked - it is not a list of what is forbidden. Whether the options are in force is isLocked.

    • Returns true if the protection has a password.

      Returns boolean

    • Checks if the object is currently locked.

      Returns boolean

      true if the object is locked, false otherwise.

      This method returns true If the lock is active.

    • Checks if the object has a locked but is paused.

      Returns boolean

      true if the object is locked but paused, false otherwise.

    • If the element is protected as readonly.

      Returns boolean

      Readonly is set cannot be changed.

    • Locks the object (workbook or sheet or range) with the specified options and password.

      Parameters

      • Optionalproperties: Partial<P>

        The properties to allow to remain unlocked. Omitted, the options the object already carries are used (see unlock and setProperties).

      • Optionalpassword: string

        The password required to unlock the object.

      • Optionalalgorithm: string

        The algorithm for encrypting the password.

      • OptionalspinCount: number

        The spin count for encrypting the password.

      Returns Promise<IProtection<T, P, J>>

      The IProtection instance for method chaining.

      By default all properties are locked but you can specify which properties to remain unlocked. Throws when the object is already protected, paused included.

    • Temporarily disables protection with the provided password.

      Parameters

      • Optionalpassword: string

        The password required to pause protection.

      Returns Promise<IProtection<T, P, J>>

      The IProtection instance for method chaining.

      This method allows temporarily pausing protection without permanently unlocking the object. Use resume to restore protection.

      Not a shortcut for unlock, even on a lock without a password: unlocking is a document change (the file saves unprotected, and the password is gone), whereas a pause keeps the whole configuration - password, options, and any session access already granted to an IProtectedRange - and resume restores it exactly. The password is required only when one is set. Throws when the object is not locked.

      The paused state is session-only and is never serialized.

    • Resumes protection that was previously paused.

      Returns IProtection<T, P, J>

      The IProtection instance for method chaining.

      This method restores protection after it was paused using the pause method.

    • Replaces the options of an unprotected or paused object. On a paused object they apply when it resumes; on an unprotected one, when it is next locked.

      Parameters

      • properties: Partial<P>

        The properties to allow to remain unlocked.

      Returns Promise<IProtection<T, P, J>>

      The IProtection instance for method chaining.

      Throws while the object is locked: unprotect or pause first. Neither asks for the password here, since an unprotected object has none and a pause already asked for it.

    • Unlocks the object (workbook or sheet) using the provided password.

      Parameters

      • Optionalpassword: string

        The password required to unlock the object.

      Returns Promise<IProtection<T, P, J>>

      The IProtection instance for method chaining.

      If the correct password is provided, protection is removed from the object and the password is cleared. The options are kept, and saved, so a later lock with no properties protects the same way again.