【发布时间】:2018-09-21 05:04:58
【问题描述】:
我在在线 Excel 中保护工作表时遇到问题。我将解锁工作表中的所有单元格,并锁定一个范围,然后保护工作表,之后工作表中的任何内容都不可编辑,甚至单元格都被解锁。此问题仅适用于 excel 在线版本,适用于已安装的桌面版本.任何人都知道如何解决这个问题或者这是一个 officeJs 错误?
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);
【问题讨论】: