Workbook Protection
Workbook protection in RadSpreadProcessing prevents users from adding, removing, renaming, or reordering worksheets. You can protect the workbook with or without a password and remove the protection when needed.
Workbook protection affects the user interface only. When a workbook is protected, the user interface does not allow users to add, delete, reorder, or rename worksheets. As a developer, you retain full access to the workbook's sheets collection and can modify it in code.
How to Protect a Workbook
To protect a workbook, call the Protect(string) method of the Workbook class. The method accepts a password string.
Example 1 illustrates how to create a workbook from scratch and protect it with a password.
Workbook protection protects the workbook structure from editing. To require a password before users can open the document, you must encrypt it. SpreadProcessing does not support encryption yet.
Example 1: Password-Protect a Workbook
Workbook workbook = new Workbook();
workbook.Worksheets.Add();
workbook.Protect("telerik");
How to Unprotect a Workbook
To remove workbook protection, call the Unprotect(string) method of the Workbook class. The method returns a Boolean value that indicates whether the workbook is successfully unprotected.
Example 2 demonstrates how to unprotect a workbook.
Example 2: Remove workbook protection by supplying the current password
Workbook workbook = new Workbook();
workbook.Worksheets.Add();
workbook.Protect("telerik");
workbook.Unprotect("telerik");