Skip to main content
Row

ChartSheet.Protect(String, ChartSheetProtection) Method

Protects chart sheet elements to prevent them from being changed by the user.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v24.1.Core.dll

NuGet Package: DevExpress.Spreadsheet.Core

Declaration

void Protect(
    string password,
    ChartSheetProtection options
)

Parameters

Name Type Description
password String

A string that specifies a password for the chart sheet. If the password is an empty string, the chart sheet can be unprotected without using a password.

options ChartSheetProtection

A ChartSheetProtection enumeration member that allows you to specify chart sheet elements to protect.

Remarks

If a chart sheet is already protected, the Protect method throws an exception. Check the ChartSheet.IsProtected property before calling the method.

Example

View Example

Worksheet worksheet = workbook.Worksheets["chartTask1"];

// Create a chart sheet containing a pie chart.
ChartSheet chartSheet = workbook.ChartSheets.Add(ChartType.Pie, worksheet["B2:C7"]);

// Protect the chart sheet. Prevent end-users from making changes to chart elements.
if (!chartSheet.IsProtected)
    chartSheet.Protect("password", ChartSheetProtection.Default);

workbook.ChartSheets.ActiveChartSheet = chartSheet;

The following code snippets (auto-collected from DevExpress Examples) contain references to the Protect(String, ChartSheetProtection) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also