Excel protect workbook with password but allow readonly

▼魔方 西西 提交于 2019-12-11 02:56:06

问题


Using the interop classes in C# I was able to protect a workbook for reading and writing with a password.

But I want users to be able to open the sheet as read-only.

Is this possible without using the Workbook.SaveAs method?

Protecting a workbook with a password (picture 1) I'm using the Workbook.Password property.


回答1:


According to MSDN, the only way to change the Workbook.ReadOnlyRecommended property is with the Workbook.SaveAs method.

In needed precisely what you're looking for a while ago (i.e. setting it without saving), but had to give in and use SaveAs. To my knowledge it's the only way.




回答2:


Use Workbook.Open(). The 3rd parameter is the read only property.

Plus a link to to the MSDN



来源:https://stackoverflow.com/questions/13138099/excel-protect-workbook-with-password-but-allow-readonly

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!