Excel.WorksheetProtectionChangedEventArgs interface

Provides information about the worksheet that raised the protection status changed event, which fires when the protection status is updated in a worksheet.

Remarks

[ API set: ExcelApi 1.14 ]

Properties

allowEditRangesChanged

Specifies if any of the AllowEditRange objects have changed.

isProtected

Gets the current protection status of the worksheet.

protectionOptionsChanged

Specifies if the WorksheetProtectionOptions have changed.

sheetPasswordChanged

Specifies if the worksheet password has changed.

source

The source of the event. It can be local or remote (through co-authoring).

type

Gets the type of the event. See Excel.EventType for details.

worksheetId

Gets the ID of the worksheet in which the protection status is changed.

Property Details

allowEditRangesChanged

Specifies if any of the AllowEditRange objects have changed.

allowEditRangesChanged: boolean;

Property Value

boolean

Remarks

[ API set: ExcelApiOnline 1.1 ]

isProtected

Gets the current protection status of the worksheet.

isProtected: boolean;

Property Value

boolean

Remarks

[ API set: ExcelApi 1.14 ]

Examples

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-worksheet-protection.yaml

async function checkProtection(event: Excel.WorksheetProtectionChangedEventArgs) {
    // This function is an event handler that returns the protection status of a worksheet
    // and information about the changed worksheet.
    await Excel.run(async (context) => {
        const protectionStatus = event.isProtected;
        const worksheetId = event.worksheetId;
        const source = event.source;
        console.log("Protection status changed. Protection status is now: " + protectionStatus + ".");
        console.log("    ID of changed worksheet: " + worksheetId + ".");
        console.log("    Source of change event: " + source + ".");
    });
}

protectionOptionsChanged

Specifies if the WorksheetProtectionOptions have changed.

protectionOptionsChanged: boolean;

Property Value

boolean

Remarks

[ API set: ExcelApiOnline 1.1 ]

sheetPasswordChanged

Specifies if the worksheet password has changed.

sheetPasswordChanged: boolean;

Property Value

boolean

Remarks

[ API set: ExcelApiOnline 1.1 ]

source

The source of the event. It can be local or remote (through co-authoring).

source: Excel.EventSource | "Local" | "Remote";

Property Value

Excel.EventSource | "Local" | "Remote"

Remarks

[ API set: ExcelApi 1.14 ]

Examples

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-worksheet-protection.yaml

async function checkProtection(event: Excel.WorksheetProtectionChangedEventArgs) {
    // This function is an event handler that returns the protection status of a worksheet
    // and information about the changed worksheet.
    await Excel.run(async (context) => {
        const protectionStatus = event.isProtected;
        const worksheetId = event.worksheetId;
        const source = event.source;
        console.log("Protection status changed. Protection status is now: " + protectionStatus + ".");
        console.log("    ID of changed worksheet: " + worksheetId + ".");
        console.log("    Source of change event: " + source + ".");
    });
}

type

Gets the type of the event. See Excel.EventType for details.

type: "WorksheetProtectionChanged";

Property Value

"WorksheetProtectionChanged"

Remarks

[ API set: ExcelApi 1.14 ]

worksheetId

Gets the ID of the worksheet in which the protection status is changed.

worksheetId: string;

Property Value

string

Remarks

[ API set: ExcelApi 1.14 ]

Examples

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/events-worksheet-protection.yaml

async function checkProtection(event: Excel.WorksheetProtectionChangedEventArgs) {
    // This function is an event handler that returns the protection status of a worksheet
    // and information about the changed worksheet.
    await Excel.run(async (context) => {
        const protectionStatus = event.isProtected;
        const worksheetId = event.worksheetId;
        const source = event.source;
        console.log("Protection status changed. Protection status is now: " + protectionStatus + ".");
        console.log("    ID of changed worksheet: " + worksheetId + ".");
        console.log("    Source of change event: " + source + ".");
    });
}