问题
Until a few weeks ago, the workbook protection API was working in Excel Online. Now it gives error as invalid parameter.
I'm setting allowInsertColumns: false
and allowFormatCells: false
.
My code looks like this:
Excel.run(function (ctx) {
var sheet = ctx.workbook.worksheets.getItem("Sheet1");
var range = sheet.getRange("A1:B3").format.protection.locked = false;
sheet.protection.protect({
allowInsertColumns: false,
allowFormatCells: false
});
$('#mytestlabel1').text("Execution of protect api call is complete");
return ctx.sync().then(function () {
$('#mytestlabel').text("Sync operation is complete");
});
}).catch(function (error) {
$('#mytestlabel').text(error.message);
console.log("Error: " + error);
if (error instanceof OfficeExtension.Error) {
console.log("Debug info: " + JSON.stringify(error.debugInfo));
}
});
I get exception when ctx.sync
is done
Does anybody know what has changed, and how to fix this?
回答1:
The product team is aware of this issue and is working on a fix.
See https://github.com/OfficeDev/office-js-docs/issues/1185 for details.
来源:https://stackoverflow.com/questions/47100262/workbook-protection-stopped-working-with-excel-online