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
Properties
allow |
Specifies if any of the |
is |
Gets the current protection status of the worksheet. |
protection |
Specifies if the |
sheet |
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 |
worksheet |
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
isProtected
Gets the current protection status of the worksheet.
isProtected: boolean;
Property Value
boolean
Remarks
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
sheetPasswordChanged
Specifies if the worksheet password has changed.
sheetPasswordChanged: boolean;
Property Value
boolean
Remarks
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
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
worksheetId
Gets the ID of the worksheet in which the protection status is changed.
worksheetId: string;
Property Value
string
Remarks
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 + ".");
});
}
Office Add-ins