Excel.ChangedEventDetail interface
提供有关 A WorksheetChangedEvent 或 TableChangedEvent的详细信息。
注解
使用方
示例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/data-change-event-details.yaml
async function onTableChanged(eventArgs: Excel.TableChangedEventArgs) {
// Inspect the values and basic types of an edited table cell, and identify errors.
await Excel.run(async (context) => {
const details: Excel.ChangedEventDetail = eventArgs.details;
const address = eventArgs.address;
if (!details) {
console.log("Edit one table cell at a time to inspect its value and type.");
return;
}
console.log(`Change at ${address}: was ${details.valueBefore}(${details.valueTypeBefore}),`
+ ` now is ${details.valueAfter}(${details.valueTypeAfter})`);
const errorType: Excel.RangeValueType = Excel.RangeValueType.error;
if (details.valueTypeAfter === errorType) {
console.log("The updated cell contains an error:", details.valueAfter);
}
});
}
属性
| value |
表示更改后的值。 返回的数据可以是字符串、数字或布尔值。 包含错误的单元格将返回错误字符串。 |
| value |
表示更改后的值的类型。 不同于 |
| value |
表示更改前的值类型。 不同于 |
| value |
表示更改之前的值。 返回的数据可以是字符串、数字或布尔值。 包含错误的单元格将返回错误字符串。 |
| value |
表示更改后的值的类型。 |
| value |
表示更改前的值类型。 |
属性详细信息
valueAfter
valueAsJsonAfter
表示更改后的值的类型。 不同于 valueAfter, valueAsJsonAfter 可以表示所有单元格值,例如格式化数字、Web 图像和实体数据类型。
valueAsJsonAfter: CellValue;
属性值
注解
valueAsJsonBefore
表示更改前的值类型。 不同于 valueBefore, valueAsJsonBefore 可以表示所有单元格值,例如格式化数字、Web 图像和实体数据类型。
valueAsJsonBefore: CellValue;
属性值
注解
valueBefore
valueTypeAfter
表示更改后的值的类型。
valueTypeAfter: Excel.RangeValueType | "Unknown" | "Empty" | "String" | "Integer" | "Double" | "Boolean" | "Error" | "RichValue";
属性值
Excel.RangeValueType | "Unknown" | "Empty" | "String" | "Integer" | "Double" | "Boolean" | "Error" | "RichValue"
注解
valueTypeBefore
表示更改前的值类型。
valueTypeBefore: Excel.RangeValueType | "Unknown" | "Empty" | "String" | "Integer" | "Double" | "Boolean" | "Error" | "RichValue";
属性值
Excel.RangeValueType | "Unknown" | "Empty" | "String" | "Integer" | "Double" | "Boolean" | "Error" | "RichValue"