# Protection

The `RadSpreadSheet` control uses the [SpreadProcessing library](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/overview) as its document model. This library provides the functionality to apply protection on a workbook or a worksheet level. Both the `Workbook` and `Worksheet` classes expose the `Protect` and `Unprotect` methods that will allow you to set a password to secure them.

> tip More information about the protection functionality of the SpreadProcessing library can be found in the [Workbook Protection](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/features/protection/workbook) and [Worksheet Protection](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/features/protection/worksheet) articles.

The following example showcases how to protect and unprotect the current worksheet:

**Defining the RadSpreadsheet and the buttons for protecting and uprotecting the current worksheet**

```XAML
<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
        <telerik:RadButton Content="Protect" 
                       Click="OnProtectButtonClicked">
            <telerik:RadButton.ContentTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <telerik:RadGlyph Glyph="{StaticResource GlyphLock}"/>
                        <TextBlock Text="{Binding}" Margin="3 0 0 0"/>
                    </StackPanel>
                </DataTemplate>
            </telerik:RadButton.ContentTemplate>
        </telerik:RadButton>
        <telerik:RadButton Content="Unprotect"
                       Click="OnUnprotectButtonClicked">
            <telerik:RadButton.ContentTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <telerik:RadGlyph Glyph="{StaticResource GlyphUnlock}"/>
                        <TextBlock Text="{Binding}" Margin="3 0 0 0"/>
                    </StackPanel>
                </DataTemplate>
            </telerik:RadButton.ContentTemplate>
        </telerik:RadButton>
    </StackPanel>
    <telerik:RadSpreadsheet x:Name="radSpreadsheet" Grid.Row="1">
        <telerik:RadSpreadsheet.FormatProviders>
            <Txt:TxtFormatProvider/>
            <Csv:CsvFormatProvider/>
        </telerik:RadSpreadsheet.FormatProviders>
    </telerik:RadSpreadsheet>
</Grid>
```

**Adding logic to the buttons**

```C#
private void OnProtectButtonClicked(object sender, RoutedEventArgs e)
{
    this.radSpreadsheet.ActiveWorksheet.Protect("Telerik", WorksheetProtectionOptions.Default);
}

private void OnUnprotectButtonClicked(object sender, RoutedEventArgs e)
{
    this.radSpreadsheet.ActiveWorksheet.Unprotect("Telerik");
}
```

> caption RadSpreadsheet with protected/unprotected worksheet

![RadSpreadsheet with protected/unprotected worksheet](https://www.telerik.com/products/wpf/documentation/assets/7b0a7488333e4ed33c96b44c634d6cd1/radspreadsheet-protection-0.gif)

## RadSpreadsheetRibbon

The protection functionality is also present in the [RadSpreadsheetRibbon](https://www.telerik.com/products/wpf/documentation/controls/radspreadsheet/spreadsheet-ui) element, which is a UI component that you can use together with RadSpreadsheet. You can find the protection logic in the **Changes** ribbon group of the **Review** tab.
