如何使用 openpyxl 在 Excel 范围内设置 user-level 权限,即 'Allow Users to Edit Ranges'?

How do I set user-level permissions on Excel ranges i.e. 'Allow Users to Edit Ranges' with openpyxl?

使用 openpyxl 和 Python 3.6,我试图在作品中设置 user-level permissions on certain rangessheet,这将允许用户编辑它(只有 sort/filter我的情况)即使 sheet 被锁定。

此屏幕截图显示了您在 Excel 2016 年如何手动执行此操作,通过 审核 -> 允许用户编辑范围:

我调查了 Named Ranges / Defined Names, but to no avail. Here are source links to worksheet and protection

如有任何帮助,我们将不胜感激!

openpyxl(2.4 和 2.5)目前无法做到这一点。可以在库的未来版本中添加对 protectedRanges(规范中的元素)的支持。