在 C# 中用于设置和使用工作表更改事件的 Excel 的 VSTO 示例?

Example of VSTO for Excel in C# for setting up and using the Worksheet Change Event?

我正在尝试在 private void ThisAddIn_Startup(object sender, System.EventArgs e) 方法中为工作表更改事件连接事件处理程序。

如果我接受使用 tab 键添加的条目,以下行将添加到 private void ThisAddIn_Startup(object sender, System.EventArgs e):

activeWorksheet.Change += ActiveWorksheet_Change;

并添加以下方法:

    private void ActiveWorksheet_Change(Excel.Range Target)
    {

    }

这可以编译但在以下位置抛出异常:

activeWorksheet.Change += ActiveWorksheet_Change;

是否有关于使用 VSTO 和 C# 将事件与 Excel 插件一起使用的示例参考?

最近有没有关于使用 VSTO 和 C# 的书籍?

使用以下代码:

this.Application.SheetChange += Application_SheetChange; 

private void Application_SheetChange(object Sh, Excel.Range Target)
{
            // your code here
}