问题
I have issue with protect worksheet in excel online. I will unlock all of the cells in the worksheet, and lock one range, then protect worksheet, after that nothing is editable in the worksheet, even the cells are unlocked.This issue only happens for excel online version, works fine for installed desktop version. Anyone has idea how to solve the problem or the is an officeJs bug?
Excel.run(function (ctx) {
//Worksheet
var sheet = ctx.workbook.worksheets.getItem("Sheet1");
//Entire Range
var entireRange = sheet.getRange();
entireRange.format.protection.locked = false;
//Specific Range
var range = sheet.getRange("A1:B5");
range.format.protection.locked = false;
//Protect Entire sheet
sheet.protection.protect({
allowInsertRows: false,
allowDeleteRows: false
});
return ctx.sync();
}).catch(errorHandler);
回答1:
This should be an issue of Office-Js API. We Office-Js API team are looking into this issue. We are tracking it by internal bug 2542108.
The worksheet will recover to editable state when user refreshes the page. I'm afraid there's no workaround you can do from API side currently.
回答2:
the issue is fixed now, this should no longer happen.
来源:https://stackoverflow.com/questions/52189194/the-entire-worksheet-is-not-editable-after-protect-the-sheet-with-some-locked-ce