The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.

How to: Protect a Chart Sheet

You can protect a chart sheet to prevent a user from making changes to chart elements. Use the ChartSheet.Protect method to apply protection to a chart sheet. Specify an optional password that should be entered to unprotect a chart sheet.

The ChartSheetProtection enumeration values enable you to specify chart sheet elements to which protection is applied. This example uses the ChartSheetProtection.Default value indicating that protection is applied to both the chart elements and graphic objects on the chart sheet.


// 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;

To remove protection, use the ChartSheet.Unprotect method.