SpreadJS Designer Component - New File

Posted by: mhill on 28 February 2022, 9:45 am EST

    • Post Options:
    • Link

    Posted 28 February 2022, 9:45 am EST

    Hi,

    I am using the SpreadJS Designer component v14.1

    When I am working with SpreadJS, I create a new workbook using it’s constructor and retain the pointer to the workbook in a variable: “spread”

     spread = new GC.Spread.Sheets.Workbook( $( '#' + spreadsheetid ).get( 0 ), newBookOptions );
    

    If the user uses the SpreadJS Designer Component to create a new workbook off the File menu, I find that my “spread” variable does not point to the new workbook. For example, any initialization I performed on the original workbook (such as registering keyboard commands) are lost when the new workbook is created.

    So my question is: Is this behavior expected? And if so, a) how can I get my spread variable to point to the new workbook. And b) is there an event I can use to re-initialize the new workbook.

    Thanks.

  • Posted 1 March 2022, 6:33 am EST

    Hi,

    This is the expected behavior as new workbook is created when you click the New Option of Designer Component.

    1. You can get the new workbook instance by using designer.getWorkbook() method.

    2. You can override the Designer FileMenuHandler’s resetCore function that is executed when the workbook is reset using Designer.

    let oldResetCore = GC.Spread.Sheets.Designer.FileMenuHandler.resetCore;
      GC.Spread.Sheets.Designer.FileMenuHandler.resetCore = function () {
        oldResetCore.apply(this, arguments);
        console.log("Reset Core ");
        // Reinitilaize your new workbook here
        // let newWorkBook = designer.getWorkbook();
        // initWorkBook(newWorkBook);
      };
    

    getWorkbook method: https://www.grapecity.com/spreadjs/docs/latest/online/SpreadJSDesigner~GC.Spread.Sheets.Designer.Designer~getWorkbook.html

    Please let us know if you face any further issues.

    Regards

    Ankit

  • Posted 1 March 2022, 7:47 am EST

    Got it. Thank you. I’ll give that a go!

    Cheers.

Need extra support?

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

Learn More

Forum Channels