Office.BeforeDocumentCloseNotification interface    
表示可在用户尝试关闭文档时显示的模式通知对话框。 在用户响应之前,文档不会关闭。 通知对话框将允许用户确认关闭文档的请求或取消关闭文档的请求。 此 API 仅在 Excel 中受支持。
注解
要求集: SharedRuntime 1.2
示例
// Enable the before document close modal notification dialog. 
async function enableNotification() {
    await Office.addin.beforeDocumentCloseNotification.enable(); 
}
// Add an event handler to detect when the document close operation is cancelled.
Office.addin.beforeDocumentCloseNotification.onCloseActionCancelled(async function () {
    // When the document close attempt is cancelled, write a message to the active range in the worksheet.
    await Excel.run(async (context) => {
        const range = context.workbook.getSelectedRange();
        range.values = [["Detected onCloseActionCancelled event."]];
        await context.sync();
    });
});    
方法
| disable() | 防止在用户尝试关闭文档时显示通知对话框。 
               | 
| enable() | 启用当用户尝试关闭文档时出现的模式通知对话框。 在用户响应之前,文档不会关闭。 此通知对话框要求用户确认关闭文档的请求,或允许用户取消关闭文档的请求。 
               | 
| on | 添加一个事件处理程序,用于检测  
 
               | 
方法详细信息
disable()
防止在用户尝试关闭文档时显示通知对话框。 
              BeforeDocumentCloseNotification API 仅在 Excel 中受支持。
disable(): Promise<void>;返回
Promise<void>
注解
要求集: SharedRuntime 1.2
enable()
启用当用户尝试关闭文档时出现的模式通知对话框。 在用户响应之前,文档不会关闭。 此通知对话框要求用户确认关闭文档的请求,或允许用户取消关闭文档的请求。 
              BeforeDocumentCloseNotification API 仅在 Excel 中受支持。
enable(): Promise<void>;返回
Promise<void>
注解
要求集: SharedRuntime 1.2
		onCloseActionCancelled(handler)
	   
	添加一个事件处理程序,用于检测 BeforeDocumentCloseNotification 何时取消关闭作。 如果满足以下两个条件,将触发此事件处理程序。
- 加载项对 对象调用 - enable方法- BeforeDocumentCloseNotification。
- 通知对话框打开时,最终用户单击对话框中 的“请勿关闭 ”按钮,单击对话框右上角的“关闭”按钮,或按 Esc 键。 
              BeforeDocumentCloseNotification API 仅在 Excel 中受支持。
onCloseActionCancelled(
            handler: () => void
        ): Promise<() => Promise<void>>;参数
- handler
- 
				() => void 
取消对话框时调用的事件处理程序。
返回
Promise<() => Promise<void>>
添加事件处理程序时解析的承诺。
注解
要求集: SharedRuntime 1.2