WorkbookSecurityLoadingOptions Class
Contains options to specify what content should be removed from a loaded workbook for security reasons.
Namespace: DevExpress.Spreadsheet
Assembly: DevExpress.Spreadsheet.v26.1.Core.dll
Declaration
Related API Members
The following members return WorkbookSecurityLoadingOptions objects:
Remarks
If matching content is located, the Workbook.SecurityLoadingOptionsViolation event fires. Set e.Handled = false in the event handler to remove the detected content, or leave it set to true to retain the content (useful for audit-only modes).
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");
}
}
Inheritance
Object
SecurityLoadingOptions
WorkbookSecurityLoadingOptions
See Also