Excel protect workbook with password but allow rea

2019-07-16 00:13发布

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

Password Dialog

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

Read Only Dialog

Is this possible without using the Workbook.SaveAs method?

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

标签: c# excel interop
2条回答
我想做一个坏孩纸
2楼-- · 2019-07-16 00:26

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.

查看更多
萌系小妹纸
3楼-- · 2019-07-16 00:39

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

Plus a link to to the MSDN

查看更多
登录 后发表回答