Excel.WorksheetFormulaChangedEventArgs interface
提供有关引发公式更改事件的工作表和公式的信息。
注解
示例
async function registerFormulaChangeHandler() {
await Excel.run(async (context) => {
// Register the formula changed event handler for the Sample worksheet.
let sheet = context.workbook.worksheets.getItem("Sample");
sheet.onFormulaChanged.add(formulaChangeHandler);
await context.sync();
});
}
async function formulaChangeHandler(event: Excel.WorksheetFormulaChangedEventArgs) {
await Excel.run(async (context) => {
// Retrieve details about the formula change event.
const cellAddress = event.formulaDetails[0].cellAddress;
const previousFormula = event.formulaDetails[0].previousFormula;
const source = event.source;
// Print out the change event details.
console.log(
`The formula in cell ${cellAddress} changed.
The previous formula was: ${previousFormula}.
The source of the change was: ${source}.`
);
});
}
属性
| formula |
获取对象的数组 如果已更改的公式数或更改的公式文本的大小超过大小限制, |
| source | 事件的源。 通过共同创作) ,它可以是本地或远程 (。 |
| type | 获取事件的类型。 有关详细信息,请参阅 |
| worksheet |
获取公式更改的工作表的 ID。 |
属性详细信息
formulaDetails
获取对象的数组 FormulaChangedEventDetail ,其中包含有关所有已更改公式的详细信息。
如果已更改的公式数或更改的公式文本的大小超过大小限制, formulaDetails 则返回 undefined。 这表示工作表上的内容已更改,但无法报告详细信息。
formulaDetails: Excel.FormulaChangedEventDetail[];
属性值
注解
source
事件的源。 通过共同创作) ,它可以是本地或远程 (。
source: Excel.EventSource | "Local" | "Remote";
属性值
Excel.EventSource | "Local" | "Remote"
注解
type
获取事件的类型。 有关详细信息,请参阅 Excel.EventType。
type: "WorksheetFormulaChanged";
属性值
"WorksheetFormulaChanged"