简体   繁体   English

Excel使用密码保护工作簿,但允许只读

[英]Excel protect workbook with password but allow readonly

Using the interop classes in C# I was able to protect a workbook for reading and writing with a password. 使用C#中的interop类,我可以保护工作簿以使用密码进行读写。

密码对话框

But I want users to be able to open the sheet as read-only. 但我希望用户能够以只读方式打开工作表。

只读对话框

Is this possible without using the Workbook.SaveAs method? 如果不使用Workbook.SaveAs方法,是否有可能?

Protecting a workbook with a password (picture 1) I'm using the Workbook.Password property. 用密码保护工作簿(图1)我正在使用Workbook.Password属性。

According to MSDN , the only way to change the Workbook.ReadOnlyRecommended property is with the Workbook.SaveAs method. 根据MSDN ,更改Workbook.ReadOnlyRecommended属性的唯一方法是使用Workbook.SaveAs方法。

In needed precisely what you're looking for a while ago (ie setting it without saving), but had to give in and use SaveAs . 正是需要您前一段时间要查找的内容(即不保存即进行设置),但必须让步并使用SaveAs To my knowledge it's the only way. 据我所知,这是唯一的方法。

Use Workbook.Open() . 使用Workbook.Open() The 3rd parameter is the read only property. 第三个参数是只读属性。

Plus a link to to the MSDN 加上指向MSDN的链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM