[英]How to set selectionMode to Unlocked? Excel add-in, Office.js
I have a small excel add-in, written in office.js and using Visual Studio 2019. Whatever I do, I can't get the add-in to protect the worksheet and allow the user to only select unlocked cells.我有一个小的 excel 加载项,用 office.js 编写并使用 Visual Studio 2019。无论我做什么,我都无法获得加载项来保护工作表并只允许用户使用 select 解锁单元格。
I've googled till my eyes bleed, best example for use is this one .我已经用谷歌搜索到我的眼睛流血了,最好的例子就是这个。 This contains many options, but not the one I want!这包含许多选项,但不是我想要的!
Microsoft documentation is here . Microsoft 文档在此处。
function ProtectSheet() {
Excel.run(function (context) {
var sheet = context.workbook.worksheets.getItem("Sheet1");
sheet.protection.protect(); //works fine, obviously doesn't achieve what I want
//here's the formats I've tried:
sheet.protection.protect({ SelectionMode: "Unlocked" });
sheet.protection.protect({ SelectionMode: unlocked });
sheet.protection.protect({ SelectionMode: Excel.ProtectionSelectionMode "Unlocked" });
sheet.protection.protect({ SelectionMode: Excel.ProtectionSelectionMode unlocked });
sheet.protection.protect({ SelectionMode?: "Unlocked" });
sheet.protection.protect({ SelectionMode?: unlocked });
sheet.protection.protect({ SelectionMode?: Excel.ProtectionSelectionMode "Unlocked" });
sheet.protection.protect({ SelectionMode?: Excel.ProtectionSelectionMode unlocked });
// all of the rest just compile to sheet.protection.protect() when viewing in the debugger;
return context.sync();
})
}
The sheet is protected, but the option to select only unused cells is not set.工作表受到保护,但未设置 select 的选项,仅未使用的单元格。
Thanks in advance!提前致谢!
Can you please try to set Unlock mode like below:您能否尝试设置解锁模式,如下所示:
sheet.protection.protect("Unlocked");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.