Detect sheet creation/deletion with events

Posted by: ian.scriven on 1 May 2018, 6:23 pm EST

  • Posted 1 May 2018, 6:23 pm EST

    Why aren't there events for sheet creation/deletion? It seems like a fairly obvious gap to me.

    I can see how to work-around the lack of a sheet creation event using active sheet changing/changed events, however that's not possible for sheet deletion, as those events don't get triggered when a user deletes a sheet (which is probably a bug?).
  • Replied 2 May 2018, 12:24 am EST


    To know when a sheet is added you can use the code as follows:

    spread.bind(GC.Spread.Sheets.Events.SheetTabClick, function (e, info) {
    if (info.sheet === null && info.sheetName === null) {
    //write your code here

    To delete sheet you must be using the Delete option available with context menu. You can handle the event for the contextmenu item.
    I hope it helps.

    Deepak Sharma
  • Replied 6 May 2018, 11:15 am EST

    Thanks Deepak for those work-arounds.

    You will also need to handle sheet insertion via the context menu. Is there a way to call the "default" command within a custom command? For example, if I replace the command for inserting a sheet, I want to still call the standard command, otherwise I'll have to implement a sheet name generator that mimics the behaviour of adding a sheet using the "+" button.

    However, the following code doesn't work:
    let commandManager = spread.commandManager();
    function insertSheet() {
    // some custom logic here
    commandManager.execute("gc.spread.contextMenu.insertSheet"); // this doesn't work
    commandManager.register("insertSheet", {canUndo: false, execute: insertSheet});

    function CustomMenuView() {
    CustomMenuView.prototype = new GC.Spread.Sheets.ContextMenu.MenuView();
    CustomMenuView.prototype.createMenuItemElement = function (menuItemData) {
    let menuItemView =, menuItemData);
    if ( === "gc.spread.insertSheet") {
    menuItemData.command = "insertSheet";
    return menuItemView;
    spread.contextMenu.menuView = new CustomMenuView();
  • Marked as Answer

    Replied 6 May 2018, 11:23 am EST

    Nevermind, I figured it out.

    For future readers:
    commandManager.execute({cmd: "gc.spread.contextMenu.insertSheet"});
  • Replied 6 May 2018, 4:02 pm EST

    Thanks for sharing the solution with us
  • Replied 2 October 2019, 12:18 pm EST


    Can you drop the code for getting an event callback for sheet deletion/context menu click of sheet deletion.

  • Replied 2 October 2019, 8:30 pm EST

    Hi Jeff,

    You could handle the ActiveSheetChanged event and check if the name of the oldSheet is set for detecting sheet deletion. Please refer to the following sample which demonstrates the same:
    Further, we have asked the dev team to add events for delete/insert sheet and will let you know about any updates regarding the same. The internal tracking ID for the issue is SJS-1954.

  • Replied 25 October 2019, 9:16 am EST

    Thanks Sharad.
  • Replied 24 April 2020, 12:23 am EST

    Hi Jeff,

    Support for detecting insert/delete/hide/unhide sheet events is now added in the latest version 13.1.0. We could use now handle the SheetChanging/SheetChanged event to handle the insert/delete/hide/unhide sheet events. Refer to the following code snippet:
    spread.bind(GC.Spread.Sheets.Events.SheetChanged, function (sender, args) {
    var sheetIndex = args.sheetIndex;

    Please update to the latest version and let us know if you face any issues. You may get the latest build from npm or download using the following link:

  • Replied 3 July 2020, 6:53 am EST

    Can you break this down into how I would detect:

    1) insert
    2 delete
    3) hide
    4) unhide
  • Replied 6 July 2020, 12:17 am EST


    You may use the propertyName field of the SheetsChanged Events Argument for the required functionality. Please refer to the following code snippet and the sample which demonstrates the same:
    spread.bind(GC.Spread.Sheets.Events.SheetChanged, function(sender, args) {
    var sheet = args.sheet;
    switch (args.propertyName) {
    case "insertSheet":
    case "deleteSheet":
    case "isVisible":
    if (args.newValue) {
    } else {


    For more information please refer to the following API References:

  • Replied 28 September 2020, 7:35 am EST

    Thank Sharad
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels