This is a migrated thread and some comments may be shown as answers.

How to catch "Worksheet Closing" event?

2 Answers 77 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
Ioannis
Top achievements
Rank 2
Ioannis asked on 27 Jan 2019, 12:00 AM

When you have a Spreadsheet  and there are n sheets on its workbook, I'd like to either get the Index of the Worksheet that is being Removed (or is Removed) or the Sheet itself when it is being removed (but when it is already removed before then I won't be able to use it to retrieve the index)

Is that possible?

The nearest event I saw was the Context Changed event of the Workbook element, but I couldn't figure it out.

2 Answers, 1 is accepted

Sort by
0
Accepted
Anna
Telerik team
answered on 30 Jan 2019, 01:23 PM
Hi,

The closest thing to what you are asking about is the Changed event of the SheetCollection. The collection can be found in the Sheets property of the workbook. It has event arguments, which specify the type of change action and the worksheet that they are performed on, however, when the action is remove, the worksheet is null. I suppose this can be easily solved by maintaining a list of names or even references to the existing worksheets and compare what is missing when the arguments indicate that a worksheet was removed.

I hope this helps.

Regards,
Anna
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Ioannis
Top achievements
Rank 2
answered on 03 Feb 2019, 12:12 PM

Hello Anna,

Thank you for your reply. I have successfully used it to do exactly what you proposed and it's not working like a SheetClosed event :)

 

Tags
Spreadsheet
Asked by
Ioannis
Top achievements
Rank 2
Answers by
Anna
Telerik team
Ioannis
Top achievements
Rank 2
Share this question
or