How to add action to custom button in FileMenu

Posted by: nguyenvu.work on 9 November 2023, 5:38 pm EST

    • Post Options:
    • Link

    Posted 9 November 2023, 5:38 pm EST

  • Posted 12 November 2023, 4:00 pm EST

    HI,

    Please refer to the following sample that demonstrates how you could add custom item in file Menu and let me know if you face any issues.

    sample: https://codesandbox.io/s/spread-js-starter-forked-xzdd7l?file=/src/index.js

    Regards,

    Avinash

  • Posted 14 November 2023, 3:33 pm EST

    Hi, thank you! It works. I wonder how can I find documents for the further problems like this.? It is too complicated, and I feel so difficult to find documents for them myself!

  • Posted 16 November 2023, 1:09 am EST

    Hi,

    Thanks for the feedback we are continually updating the docs to make them better. For complicated issues, you could always create a support case. We will be happy to help you.

    Regards,

    Avinash

  • Posted 16 November 2023, 8:53 pm EST

    Hi,

    • I got it!
    • And I have other problems:
    • 1: I am wanting to bind action when cell’s value changed, I used GC.Spread.Sheets.Events.ValueChanged then it works on most of user’s actions except pressing the “Delete” on keyboard. How can I catch it. I tried some other action binding like GC.Spread.Sheets.Events.EditEnded but it’s not works too.
    • 2: In my app, there is import work book function, I am using excelIO.open to get workbook’s json, but When I show it on the spreadjs, rowCount and colCount were only set next to last cell which contain value, That look so weird, I am about to set default rowCount and colCount depend on sheet.geRowCount() and sheet.getColCount() after .fromJSON(). Is there any better solution for my case?
  • Posted 19 November 2023, 4:08 pm EST

    HI,

    1. spreadJS fires RangeChanged event for actions that change the range of the cell. You may need to use RangeChanged event for handling the delete key. Please refer to the following code snippet and let me know if you face any issues.
    
     activeSheet.bind(GC.Spread.Sheets.Events.RangeChanged, function (sender, args) {
      console.log(args.sheetName, args.action);
    });

    API:

    RangeChanged: https://developer.mescius.com/spreadjs/api/v15/classes/GC.Spread.Sheets.Events#rangechanged

    List of actions: https://developer.mescius.com/spreadjs/api/v16/enums/GC.Spread.Sheets.RangeChangedAction#enumeration-rangechangedaction

    1. This is expected, SpreadJS only imports the last used cells from Excel. For this what you could do is after importing the Excel file use the setRowCount and setColumnCount methods to define the rowCount and colCount. Please refer to the following code snippet and let me know if you face any issues.
    //import the Excel first 
    let sheet = spreadInstance.getSheetFromName('NameOfThe ');
    sheet.setColumnCount(40);
    sheet.setRowCount(400);

    API:

    setColumnCount: https://developer.mescius.com/spreadjs/api/v15/classes/GC.Spread.Sheets.Worksheet#setcolumncount

    setRowCount: https://developer.mescius.com/spreadjs/api/v15/classes/GC.Spread.Sheets.Worksheet#setrowcount

  • Posted 26 November 2023, 6:01 pm EST

    Thank you so much!

Need extra support?

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

Learn More

Forum Channels