modern-xlsx API Reference - v1.3.0
    Preparing search index...

    Interface SheetProtectionData

    Sheet protection: the <sheetProtection> element (ECMA-376 Part 1 §18.3.1.85).

    Every flag except sheet says whether an action is locked while the sheet is protected: true blocks the action in Excel, false allows it. Excel enforces the flags only when sheet is true. An optional flag left out takes the default shown on it, and a workbook read back omits an optional flag that is at its default.

    To protect with a password, set plainPassword. password and the algorithmName, hashValue, saltValue and spinCount group hold the hash a file carries; they are written back unchanged, and a password that is not 1 to 4 hex digits fails the write.

    interface SheetProtectionData {
        algorithmName?: string | null;
        autoFilter: boolean;
        deleteColumns: boolean;
        deleteRows: boolean;
        formatCells: boolean;
        formatColumns: boolean;
        formatRows: boolean;
        hashValue?: string | null;
        insertColumns: boolean;
        insertHyperlinks?: boolean;
        insertRows: boolean;
        objects: boolean;
        password?: string | null;
        pivotTables?: boolean;
        plainPassword?: string | null;
        saltValue?: string | null;
        scenarios: boolean;
        selectLockedCells?: boolean;
        selectUnlockedCells?: boolean;
        sheet: boolean;
        sort: boolean;
        spinCount?: number | null;
    }
    Index
    algorithmName?: string | null

    Hash algorithm of hashValue as stored in the file, such as 'SHA-512'.

    autoFilter: boolean

    true locks AutoFilter use; false allows it (schema default true).

    deleteColumns: boolean

    true locks deleting columns; false allows it (schema default true).

    deleteRows: boolean

    true locks deleting rows; false allows it (schema default true).

    formatCells: boolean

    true locks formatting cells; false allows it (schema default true).

    formatColumns: boolean

    true locks formatting columns; false allows it (schema default true).

    formatRows: boolean

    true locks formatting rows; false allows it (schema default true).

    hashValue?: string | null

    Base64 iterated password hash as stored in the file.

    insertColumns: boolean

    true locks inserting columns; false allows it (schema default true).

    insertHyperlinks?: boolean

    true locks inserting hyperlinks; false allows it. Omitted means true.

    insertRows: boolean

    true locks inserting rows; false allows it (schema default true).

    objects: boolean

    true locks shapes, charts and other objects; false allows editing them (schema default false).

    password?: string | null

    The legacy 16-bit password hash a file stores (1 to 4 hex digits), never the password itself: any other value makes the write throw INVALID_WORKBOOK and validate() report it, and it is not hashed for you, because a password such as 'cafe' is also a valid hash.

    pivotTables?: boolean

    true locks PivotTable use; false allows it. Omitted means true.

    plainPassword?: string | null

    The password to protect the sheet with, the only field that takes one: on write it replaces password and the stored hash with a fresh hash (SHA-512, random 16-byte salt, 100,000 iterations, as Excel writes it; modern-xlsx/lite writes the legacy 16-bit password hash and accepts ASCII passwords only). Write-only: a workbook read back carries the hash, never this field.

    saltValue?: string | null

    Base64 salt of hashValue as stored in the file.

    scenarios: boolean

    true locks scenarios; false allows editing them (schema default false).

    selectLockedCells?: boolean

    true blocks selecting locked cells; false allows it. Omitted means false.

    selectUnlockedCells?: boolean

    true blocks selecting unlocked cells; false allows it. Omitted means false.

    sheet: boolean

    true protects the sheet: locked cells cannot be edited and the flags below apply.

    sort: boolean

    true locks sorting; false allows it (schema default true).

    spinCount?: number | null

    Hash iterations of hashValue as stored in the file.