[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
    Product Structure
   [Expand]Getting Started
   [Expand]Spreadsheet Document
    Supported Formats
   [Expand]Cell Basics
    Defined Names
    Data Binding
    Data Validation
   [Expand]Data Presentation
   [Expand]Pivot Table Overview
   [Expand]Charts and Graphics
    Find and Replace
   [Expand]Mail Merge
   [Expand]Visual Elements
    Themes and Templates
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)


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.

Open the Encrypted File

The table below lists ways to specify a password to open the encrypted file.

Method Description
The WorkbookImportOptions.Password setting. If this property contains the correct password, a document is loaded. If the password is not specified or is invalid, the SpreadsheetControl.EncryptedFilePasswordRequest event occurs.
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.
A dialog prompts the end user for a password.

If neither method provides a correct password, the SpreadsheetControl.EncryptedFilePasswordCheckFailed event occurs. Handle this event to obtain the error that led to this event (EncryptedFilePasswordCheckFailedEventArgs.Error) and determine whether to prompt a user for a password (EncryptedFilePasswordCheckFailedEventArgs.TryAgain).

When the EncryptedFilePasswordCheckFailedEventArgs.TryAgain property is set to false, a warning message is displayed and the Spreadsheet control creates an empty document. The message contains localized text specified by the XtraSpreadsheetStringId.Msg_IncorrectPassword enumeration member.


If an encrypted file is loaded using the SpreadsheetControl.DocumentSource property, its format cannot be detected. Use the SpreadsheetDocumentSource instance to bind encrypted files.

Save the Encrypted File

You can specify a password to save the encrypted file in the following ways.



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 allows end-users to specify a password to encrypt the contents of the document when it is saved to a file. To provide end-users with the capability to invoke the Encrypt Document dialog, add the Info Ribbon page group to the SpreadsheetControl.

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 worksheet by using the following dialog:

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 has the Protection.Locked attribute set to true. When protection is applied to the worksheet, these cells becomes read-only. The SpreadsheetControl.ProtectionWarning event occurs on an attempt to edit a locked cell.

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.


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

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

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 particular 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:

Is this topic helpful?​​​​​​​