You are actually doing the opposite of what you want here. When you install allowInsertRows: true, you unprotect the line insert. Since you are not protecting anything, the password you provided is simply ignored.
allowInsertRows: false, . , :
Excel.run(function (ctx) {
var sheet = ctx.workbook.worksheets.getItem("Sheet1");
sheet.protection.protect({
allowInsertRows: false
}, "mypassword");
return ctx.sync();
}).catch(function (error) {
console.log("Error: " + error);
if (error instanceof OfficeExtension.Error) {
console.log("Debug info: " + JSON.stringify(error.debugInfo));
}
});
, . locked :
var range = sheet.getRange("A1:B3").format.protection.locked = false;
: , ( , ):
Excel.run(function (ctx) {
var sheet = ctx.workbook.worksheets.getItem("Sheet1");
var range = sheet.getRange("A1:B3").format.protection.locked = false;
sheet.protection.protect({
allowInsertRows: true
});
return ctx.sync();
}).catch(function (error) {
console.log("Error: " + error);
if (error instanceof OfficeExtension.Error) {
console.log("Debug info: " + JSON.stringify(error.debugInfo));
}
});
. , . , .