[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
   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
    Shapes
    Printing
    Protection
    Find and Replace
   [Expand]Mail Merge
   [Expand]Visual Elements
    Services
    Themes and Templates
   [Expand]Shortcuts
   [Collapse]Examples
    [Expand]Files
    [Expand]Workbooks
    [Expand]Worksheet
    [Expand]Rows and Columns
    [Expand]Cells
    [Expand]Formulas
    [Expand]Data Binding
    [Expand]Formatting Cells
    [Expand]Conditional Formatting
    [Expand]Group Data
    [Expand]Filter Data
    [Expand]Tables
    [Expand]Pivot Tables
    [Expand]Printing
    [Expand]Pictures
    [Expand]Charts
    [Collapse]Protection
      How to: Protect a Workbook
      How to: Protect a Worksheet
      How to: Protect Specific Worksheet Ranges
    [Expand]Mail Merge
    [Expand]Cell Templates
    [Expand]Customization
  [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]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [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]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

How to: Protect Specific Worksheet Ranges

You can unlock specific ranges in a protected worksheet for the end-user who provide the required credentials. When an end-user attempts to edit a cell in the range, the Spreadsheet control sends a request to identify the user. The end-user may be prompted for a password, or can be silently authenticated with the Windows Active Directory services by the user account under which the spreadsheet application runs. If two mentioned options are specified for the same range, the Active Directory services are queried first, and if authentication fails, a password dialog is invoked.

To apply range protection, create a ProtectedRange object for the required range.

To use password authentication, specify the password using the ProtectedRange.SetPassword method.

To use Windows Active Directory services, create an EditRangePermission object for each user or group, transform a list of permissions to a security descriptor by using the ProtectedRange.CreateSecurityDescriptor method and specify the security descriptor for the range by using the ProtectedRange.SecurityDescriptor method.

The following code illustrates both options.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E4944.

The entire worksheet is protected with a "password" password. End-users can only select cells.

On an attempt to edit range "C3:E8" on a protected sheet, the end-user will be prompted for a password ("123") unless the application which loaded the worksheet is not run under the same account as the application which has executed the following code snippet. If it is so, a password is not required to edit the range "C3:E8".

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