I'm currently working on Angular Based Office Add-in for Excel where data tables are moved in and out of a server. Based on the microsoft documentation, I'm using the shown method for tracking changes in a given worksheet for any type of change however when a row is deleted, it notices that a delete event has occurred but it does not have the value of the row that was deleted. I am able to capture the data when individual cells are modified or added or even deleted using backspace. However, when a range of data has been changed, the event is not able to capture the data that was changed.
The goal is to capture the data that was edited/added/deleted from the excel tables but I am unable to do so when the event occurs over a range. Is there another function that can track changes over a range of data?
async trackSheetData(worksheetName: string) {
await Excel.run(async (context) => {
let sheet = context.workbook.worksheets.getItem(worksheetName);
sheet.onChanged.add(this.handleChange);
});
}
//function to handle changes
async handleChange(event) {
await Excel.run(async (context) => {
let activeSheet = context.workbook.worksheets.getActiveWorksheet();
activeSheet.load("name");
await context.sync();
console.log("Change type of event: " + event.changeType);
console.log("Address of event: " + event.address);
console.log("Sheet change occured on: " + activeSheet.name);
console.log(event);
}).catch((err) => console.log(err));
}
Cases:
- Added Entry to sheet on empty cell: EventDetails-AddNew
- Modified single cell in sheet: EventDetails-Modified
- Delete Row (range): EventDetails-DeleteRow
- Used the drag option to modify a whole range of data: EventDetails-ModifyRange