1

As the title says, is there an event for those actions like deleting a row or column, inserting a row or column, or changing text in a cell? I'd be very disappointed if there isn't.

newman
  • 6,841
  • 21
  • 79
  • 126

1 Answers1

1

When you delete or insert a row or column, the RangeChanged event of the WorkbookView class fires. For example, if you delete a column, you can see the address of the column from the RangeChangedEventArgs.

public void workbookView1_RangeChanged(object sender, RangeChangedEventArgs e)
{
    //if column D is deleted, address = "$D:$D"
    string address = e.Range.Address
}

A useful event for handling text entered in a cell is the CellEndEdit event of the WorkbookView class which fires when a user finishes editing a cell.

private void workbookView1_CellEndEdit(object sender, CellEndEditEventArgs e)
{
  IRange range = e.RangeSelection;
  string entry = e.Entry;
}
Daniel
  • 5,602
  • 4
  • 33
  • 36
  • 1
    Okay, RangeChanged event is fired a lot. But how do I know if the range is deleted or inserted? From my testing, I got the same range for deleting or inserting. – newman Dec 12 '12 at 16:23
  • 1
    You're right, there is nothing in the RangeChanged event that will tell you whether a range is inserted or deleted. Other than knowing the state of the range before the range is changed, I don't know how you can determine the type of change. There are no range insertion or deletion events that I am aware of. – Daniel Dec 12 '12 at 17:03