Excel.WorksheetProtectionChangedEventArgs interface

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

注解

[ API 集:ExcelApi 1.14 ]

属性

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