Excel.WorksheetProtectionChangedEventArgs interface

提供有关引发保护状态更改事件的工作表的信息,该事件在更新工作表中的保护状态时触发。

属性

allowEditRangesChanged

指定是否有任何 AllowEditRange 对象已更改。

isProtected

获取工作表的当前保护状态。

protectionOptionsChanged

指定是否 WorksheetProtectionOptions 已更改。

sheetPasswordChanged

指定工作表密码是否已更改。

source

事件的源。 它可以是本地的,也可以通过共同创作) 远程 (。

type

获取事件的类型。 有关详细信息,请参阅 Excel.EventType

worksheetId

获取保护状态在其中更改的工作表的 ID。

属性详细信息

allowEditRangesChanged

指定是否有任何 AllowEditRange 对象已更改。

allowEditRangesChanged: boolean;

属性值

boolean

注解

API 集:ExcelApiOnline 1.1

isProtected

获取工作表的当前保护状态。

isProtected: boolean;

属性值

boolean

注解

API 集:ExcelApi 1.14

示例

// 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

指定是否 WorksheetProtectionOptions 已更改。

protectionOptionsChanged: boolean;

属性值

boolean

注解

API 集:ExcelApiOnline 1.1

sheetPasswordChanged

指定工作表密码是否已更改。

sheetPasswordChanged: boolean;

属性值

boolean

注解

API 集:ExcelApiOnline 1.1

source

事件的源。 它可以是本地的,也可以通过共同创作) 远程 (。

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

属性值

Excel.EventSource | "Local" | "Remote"

注解

API 集:ExcelApi 1.14

示例

// 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

获取事件的类型。 有关详细信息,请参阅 Excel.EventType

type: "WorksheetProtectionChanged";

属性值

"WorksheetProtectionChanged"

注解

API 集:ExcelApi 1.14

worksheetId

获取保护状态在其中更改的工作表的 ID。

worksheetId: string;

属性值

string

注解

API 集:ExcelApi 1.14

示例

// 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 + ".");
    });
}