Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[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
  Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
   Reporting
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Collapse]Spreadsheet
    Product Structure
   [Expand]Getting Started
   [Expand]Spreadsheet Document
    Supported Formats
   [Expand]Cell Basics
   [Expand]Formulas
    Defined Names
    Data Binding
    Data Validation
   [Expand]Data Presentation
   [Expand]Pivot Table Overview
   [Expand]Charting Overview
    Printing
    Protection
    Find and Replace
   [Expand]Visual Elements
    Services
    Themes and Templates
   [Expand]Examples
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Diagram Control
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[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 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.
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 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. 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 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:

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