C# Programming
08-24-2009, 04:41 PM
Hello,
I have a C# program that uses the Excel interop (Microsoft.Office.Interop.Excel) to monitor an Excel 2007 spreadsheet.
I use the delegate named WorkbookEvents_SheetChangeEventHandler which runs my custom code when any cell on the spreadsheet is updated. But the following code is not working..
I think I didn't use the delegate WorkbookEvents_SheetChangeEventHandler,correctly.Please let me know how to raise the event whenever the cell in excel file gets changed.
Thanks in advance.
using excel=Microsoft.Office.Interop.Excel;
public event excel.WorkbookEvents_SheetChangeEventHandler SheetChange;
private void WorkbookSheetChange()
{
this.SheetChange += new excel.WorkbookEvents_SheetChangeEventHandler(workSheet_SheetChange);
}
void workSheet_SheetChange(object Sh, excel.Range Target)
{
Target = range;
string changedRange = Target.get_Address(1, 1,
excel.XlReferenceStyle.xlA1, 1, 1);
MessageBox.Show("The value of " + workSheet.Name + ":" +
changedRange + " was changed.");
}
I have a C# program that uses the Excel interop (Microsoft.Office.Interop.Excel) to monitor an Excel 2007 spreadsheet.
I use the delegate named WorkbookEvents_SheetChangeEventHandler which runs my custom code when any cell on the spreadsheet is updated. But the following code is not working..
I think I didn't use the delegate WorkbookEvents_SheetChangeEventHandler,correctly.Please let me know how to raise the event whenever the cell in excel file gets changed.
Thanks in advance.
using excel=Microsoft.Office.Interop.Excel;
public event excel.WorkbookEvents_SheetChangeEventHandler SheetChange;
private void WorkbookSheetChange()
{
this.SheetChange += new excel.WorkbookEvents_SheetChangeEventHandler(workSheet_SheetChange);
}
void workSheet_SheetChange(object Sh, excel.Range Target)
{
Target = range;
string changedRange = Target.get_Address(1, 1,
excel.XlReferenceStyle.xlA1, 1, 1);
MessageBox.Show("The value of " + workSheet.Name + ":" +
changedRange + " was changed.");
}