如何设置selectMode为Unlocked?Excel插件,Office.js

问题描述 投票:1回答:1

我有一个小型的excel插件,用office.js编写,使用Visual Studio 2019。 无论我做什么,我都无法让插件保护工作表,并允许用户只选择未锁定的单元格。

我已经谷歌到我的眼睛流血,最好的使用的例子是 这个. 这里面包含了很多选项,但不是我想要的那个!

微软的文档是 此处.

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();
     })
}

工作表被保护了,但没有设置只选择未使用的单元格的选项。

先谢谢了!

excel office-js excel-addins
1个回答
0
投票

能否请你尝试像下面这样设置解锁模式。

sheet.protection.protect("Unlocked");
© www.soinside.com 2019 - 2024. All rights reserved.