Skip to main content
All docs
V26.1
  • Row

    Workbook.Sanitize(WorkbookSanitizeOptions) Method

    Sanitizes the workbook content according to the specified options.

    Namespace: DevExpress.Spreadsheet

    Assembly: DevExpress.Docs.v26.1.dll

    Declaration

    public IReadOnlyList<WorkbookSanitizeResult> Sanitize(
        WorkbookSanitizeOptions options
    )

    Parameters

    Name Type Description
    options WorkbookSanitizeOptions

    The options that specify the content to sanitize and the action to perform with it.

    Returns

    Type Description
    IReadOnlyList<WorkbookSanitizeResult>

    A list of results that contain information about the sanitized content.

    Remarks

    Call Workbook.Sanitize(WorkbookSanitizeOptions) to remove personal data and internal organizational information from loaded documents before sharing, publishing, or archiving them. The method accepts a WorkbookSanitizeOptions object that specifies which content categories to sanitize.

    The method returns a list of WorkbookSanitizeResult objects. Each object records the detected content type and action taken. Together, these objects provide a structured record of sanitization operations in the document.

    Example

    How to: Sanitize a Spreadsheet Document

    The following code snippet sanitizes hidden sheets and comments from a spreadsheet:

    using DevExpress.Office;
    using DevExpress.Spreadsheet;
    
    using (Workbook workbook = new Workbook())
    {
        workbook.LoadDocument("Documents\\Sample.xlsx");
    
        WorkbookSanitizeOptions sanitizeOptions = new WorkbookSanitizeOptions
        {
            RemoveThreadedComments = true,
            HiddenSheets = HiddenContentSanitizeMode.MakeVisible
        };
    
        var results = workbook.Sanitize(sanitizeOptions);
    
        foreach (var result in results)
        {
            Console.WriteLine($"Content type: {result.Type}, Action taken: {result.Action}");
        }
    }
    
    See Also