Excel.WorksheetProtectionChangedEventArgs interface

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

注解

[ API 集:ExcelApi 1.14 ]

属性

isProtected

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

source

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

type

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

worksheetId

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

属性详细信息

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

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