allowExtendPasteRange not working on protectedSheet?

Posted by: razeris563 on 9 September 2021, 5:14 am EST

  • Posted 9 September 2021, 5:14 am EST

    Hi guys! I am using :

    spread.options.allowExtendPasteRange = true;
    

    And it works perfectly fine on a sheet that isn’t protected, but it doesn’t work on the one that is. I tried to add it again in the “protecting phase” but it didn’t work again.

    Is there a way to enable ```

    allowExtendPasteRange

  • Posted 13 September 2021, 2:53 am EST

    Thank you Avinash. May I ask whether it’s possible to restrict adding columns to this protected sheet and only enable

    allowExtendPasteRange
    only for rows?

  • Posted 14 September 2021, 5:12 am EST

    Hi,

    This is expected behavior what happening here is when we extended range while pasting there are two invalid actions.

    1. We could not insert rows and columns in the protected sheet.
    2. The added rows/columns are locked so even if we insert the row or column, we could not change the inserted cells since those are locked.

    For fixing the 1st issue we need to use the insert rows and insert columns protection options and set it as true so that inserting actions could be performed and for the 2nd issue, we need to set the default protection state for all the cells as unlocked so that inserted rows and columns should be unlocked.

    Please refer to the following code snippet and let us know if you face any issues.

    
     let sheet = spread.getSheet(0);
      sheet.setRowCount(10);
      sheet.setColumnCount(4);
      //set the protection options
      sheet.options.isProtected = true;
      sheet.options.protectionOption = {};
      sheet.options.protectionOption.allowInsertRows = true;
      sheet.options.protectionOption.allowInsertColumns = true;
      //
      //set all the cell default states as unlocked
      //
    
      let style = new GC.Spread.Sheets.Style();
      style.locked = false;
      sheet.setDefaultStyle(style);
      spread.resumePaint();
    
    

    sample: https://codesandbox.io/s/spread-js-starter-forked-9v7s1?file=/src/index.js:266-750

    Regards

    Avinash

  • Posted 14 September 2021, 5:19 am EST

    Hi,

    We are sorry but allowExtendRange work on the Range. We could not set it to extend only the rows. We could only lock the cells on which we do not want to perform the pasting.

    If the range has bigger the columns will be inserted we are sorry for the inconvenience.

    Regards

    Avinash

Need extra support?

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

Learn More

Forum Channels