Predefine column/row count of sheets via option

Posted by: davide.vago on 8 April 2021, 2:17 am EST

  • Posted 8 April 2021, 2:17 am EST

    Dear support,

    I'm trying to understand if there is an option which permits to define a minimum number of columns/rows so when the user hits the add button from the status bar it automatically create new sheets with a defined columns/rows.

    It probably would be within the WorkBook or the WorkSheet classes but I can't find anything within the documentation.

    Looking forward to hearing from you
  • Replied 8 April 2021, 5:12 pm EST

    Hi Davide,

    We are sorry but currently, there is no is public API available for changing the Worksheet default Row and column count. What you could do is change the row count or column count whenever the new Sheet added(inside the SheetChanged Event). Please refer to the following code snippet and attached sample that demonstrates the same.


    spread.bind(GC.Spread.Sheets.Events.SheetChanged, function (sender, args) {
    if (args.propertyName === "insertSheet") {
    setDefaultRowCount(spread.getSheet(args.sheetIndex));
    }
    });

    function setDefaultRowCount(sheet) {
    sheet.suspendPaint();
    let defaultRowCount = 10;
    sheet.setRowCount(defaultRowCount);
    sheet.resumePaint();
    }



    Sample: https://codesandbox.io/s/funny-ishizaka-fcmnr?file=/src/index.js


    SheetChanged: https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS~GC.Spread.Sheets.Events~SheetChanged_EV.html'

    Regards
    Avinash
  • Replied 8 April 2021, 8:18 pm EST

    Thanks Avinash,

    Would it be possible to expose this option in future releases? It would be a good addition as we don't need to customise the onSheetChange event (also because the above snippet doesn't take in consideration pre-existing and pre-populated sheets)

    If anything to cover it up the customisation should be within an "onSheetAdd" or something similar

Need extra support?

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

Learn More

Forum Channels