Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Collapse]Spreadsheet
   [Expand]Product Information
    Product Structure
    Getting Started
   [Expand]Spreadsheet Document
    Supported Formats
   [Expand]Cell Basics
   [Expand]Spreadsheet Formulas
    Defined Names
    Data Binding
    Data Validation
   [Expand]Data Presentation
    Data Grouping
   [Expand]Pivot Table Overview
   [Expand]Charting Overview
    Printing
    Events
   [Expand]Mail Merge Overview
    Protection
    Find and Replace
   [Expand]Visual Elements
    Services
   [Expand]Shortcuts
   [Expand]Examples
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Protection

The Spreadsheet control enables you to use password encryption to prevent unauthorized people from opening or modifying your workbooks. It also offers a workbook protection functionality to restrict changes to workbooks, worksheets, and specific ranges. In a protected workbook, worksheets cannot be added, deleted or renamed by users. Also, users are prohibited from moving worksheets within the workbook. A protected worksheet does not allow a user to change cell values or modify the worksheet in other ways. Also, different sheets can have different levels of protection. For example, a range in a protected worksheet can be unlocked for specific users (the Windows domain security model is used), but other users may be prompted for a password when they try to edit the range.

Expanded File Password Encryption

The Spreadsheet control can open and save password encrypted files in binary (.xls) and OpenXml (.xlsx) formats.

A password to open the encrypted file can be specified in different ways, which are listed in the table below.

Method

Description

The WorkbookImportOptions.Password setting. If this property contains the correct password, a document is loaded. Otherwise, the SpreadsheetControl.EncryptedFilePasswordRequest event occurs. If the event is not handled, a Password dialog prompts the end-user for a password.
The SpreadsheetControl.EncryptedFilePasswordRequest event. Subscribe to this event and specify a password using the EncryptedFilePasswordRequestEventArgs.Password property. Set the e.Handled property to true to not display a dialog that prompts the end-user for a password.
The Password dialog. A dialog prompts the end-user for a password.

If neither method provides a correct password, a warning message is displayed and the Spreadsheet control loads an empty document. The message contains localized text specified by the XtraSpreadsheetStringId.Msg_IncorrectPassword enumeration member.

A password to save the encrypted file can be specified in the following ways.

Method

Description

The DocumentSettings.Encryption property. Use the EncryptionOptions.Type property to set the desired encryption type and the EncryptionOptions.Password property to specify a password to encrypt a document.
The Encrypt Document dialog. The Encrypt Document dialog allows end-users to specify a password to encrypt the contents of the document when it is saved to a file.

Expanded Workbook Protection

You can protect a workbook to lock its structure or freeze/unfreeze windows. For this purpose, use the IWorkbook.Protect method. You can provide an optional password parameter to prompt the end-user for a password to unprotect a worksheet. To unprotect a worksheet, use the IWorkbook.Unprotect method.

An end-user can protect a workbook using the following dialog.

The end-user interface for workbook protection is described in greater detail in the Protect Workbook Dialog topic.

Expanded Worksheet Protection

You can protect a worksheet to lock the cells so that end-users can only perform a specific (restricted) set of actions.

By default, all cells in the worksheet have the Protection.Locked attribute set to true. When protection is applied to the worksheet, these cells become read-only. Cells with the Protection.Locked attribute set to false are not protected when worksheet protection is applied, so that the end-users can edit their contents.

To apply worksheet protection, use the Worksheet.Protect method. You can provide an optional password parameter to prompt the end-user for a password to unprotect a worksheet. To unprotect a worksheet, use the Worksheet.Unprotect method.

By default (when you pass the WorksheetProtectionPermissions.Default parameter to the Protect method), a protected worksheet is locked so that the user is only able to select cells.

Note

The Select locked cells and Select unlocked cells options (the WorksheetProtectionPermissions.SelectLockedCells and the WorksheetProtectionPermissions.SelectUnlockedCells parameters) do not affect SpreadsheetControl behavior. These cells are always selectable.

An end-user can protect a worksheet using the following dialog.

The end-user interface for worksheet protection is described in greater detail in the Protect Sheet Dialog topic.

Expanded Unlock Ranges in a Protected Worksheet

Cells with the Protection.Locked attribute set to false are editable when worksheet protection is applied. However, you might wish to protect the range of cells so that it is editable only for authenticated users. Here is a brief guide on how to accomplish this.

The Worksheet.ProtectedRanges collection contains ranges that can be unlocked for users providing the required credentials. A user can be authenticated in one of the following ways.

  • Authentication that uses the user account under which the spreadsheet application runs. The authentication itself is performed by Windows and the control uses standard security mechanisms that rely on domain security. The text that follows provides short instructions on how to associate a specific user with a particular range in a worksheet.

    To unlock a range for a specific user or user group, perform the following steps. Create an EditRangePermission object for each user or group. Transform a list of permissions to a security descriptor by using the ProtectedRange.CreateSecurityDescriptor method. Specify the security descriptor for the range by using the ProtectedRange.SecurityDescriptor method.

  • Authentication that uses a password. To specify a password for the range, use the ProtectedRange.SetPassword method. When an attempt is made to edit the range, the user will be prompted for a password.

Note that these permissions are in effect on a protected worksheet (use the Worksheet.Protect method).

An end-user can specify unlocked ranges in the following dialog.

For more details on the end-user interface, see the User Permissions Dialog topic.

Expanded See Also

How would you rate this topic?​​​​​​​