How to catch "Worksheet Closing" event?

3 posts, 1 answers
  1. Ioannis
    Ioannis avatar
    35 posts
    Member since:
    Dec 2018

    Posted 26 Jan Link to this post

    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. Answer
    Anna
    Admin
    Anna avatar
    136 posts

    Posted 30 Jan Link to this post

    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.
  3. Ioannis
    Ioannis avatar
    35 posts
    Member since:
    Dec 2018

    Posted 03 Feb Link to this post

    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 :)

     

Back to Top