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.
- We could not insert rows and columns in the protected sheet.
- 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