Workbook.SecurityLoadingOptionsViolation Event
Occurs when the security loading options are violated while loading a workbook.
Namespace: DevExpress.Spreadsheet
Assembly: DevExpress.Docs.v26.1.dll
Declaration
public event EventHandler<SecurityLoadingOptionsViolationEventArgs> SecurityLoadingOptionsViolation
Event Data
The SecurityLoadingOptionsViolation event's data class is SecurityLoadingOptionsViolationEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Handled | Gets or sets whether the event is handled. |
| PropertyName | Gets the name of the property that was violated. |
Example
How to: Set Security Loading Options and Handle Violations
The following code snippet sets SecurityLoadingOptions and handles the SecurityLoadingOptionsViolation event:
using DevExpress.Spreadsheet;
using (Workbook workbook = new Workbook())
{
WorkbookSecurityLoadingOptions securityLoadingOptions = workbook.Options.SecurityLoadingOptions;
securityLoadingOptions.RemoveMacros = true;
securityLoadingOptions.RemoveActiveXContent = true;
securityLoadingOptions.RemoveOleObjects = true;
securityLoadingOptions.RemoveRestrictedFormulas = true;
securityLoadingOptions.RemoveExternalWorkbooks = true;
securityLoadingOptions.RemoveExternalConnections = true;
securityLoadingOptions.RemovePivotCaches = true;
securityLoadingOptions.RemoveCustomXMLParts = true;
workbook.SecurityLoadingOptionsViolation += (_, e) => {
Console.WriteLine($"Dangerous content found: {e.PropertyName}");
e.Handled = false; // false = remove the content
workbook.LoadDocument("Documents\\Sample.xlsx");
}
}
See Also