How to: Protect a Chart

After you create a chart, you can apply chart protection to prevent your chart from being modified by a user. Use the ChartOptions.Protection property to protect a chart. After chart protection is specified, the chart becomes completely locked, so that an end-user cannot select the chart, modify its elements or change chart data references.

You can also protect the entire worksheet where the chart is located by using the Worksheet.Protect method. For detailed information on the protection functionality in the SpreadsheetControl, refer to the Protection article.

The following example demonstrates how to create and protect a clustered column chart.

// Create a chart and specify its location.
Chart chart = worksheet.Charts.Add(ChartType.ColumnClustered, worksheet["B2:D4"]);
chart.TopLeftCell = worksheet.Cells["H2"];
chart.BottomRightCell = worksheet.Cells["N14"];

// Apply the chart protection.
chart.Options.Protection = ChartProtection.All;
See Also