v0.5.0 ||

Excel Change Handler

C# library to detect and process changes made to Excel worksheets

Gitlab
Docs
MIT

2020.05.11 2022.03.20

Project archived on 18 November 2022


This library enables data changes in an Excel workbook to be detected and handled in a VSTO addin.

The initial use-case was to automatically colour and log any changes to an Excel workbook. When working with certain workbooks that would later require peer-review, users were advised to manually update the background colour of any cells they changed. This helped other people quickly find and peer-review those changes and ensure they are correct. This library allows that process to be fully automated.


This functionality is more complicated that it should be because the Excel event API for cell changes only includes the new data. The data the cell contained before it was changed is no longer available when the event is triggered. To work around this, the library remembers the data of each cell that is selected (before the cell is changed) and then compares its own memory against the new data.

That is why the library has before change and after change handler functions. The before function should be hooked into events that fire before a change is made to store the cell data that is about to be changed. Examples of this are selection changed and sheet activated events. The after event should be hooked into events that fire after a cell is changed. For example, the cell changed event.

Once the after change event handler is called, it will check the new data against the previous state it has in memory and, if the data has changed, invoke all the change handlers which have been registered.