This module uses the DevExpress Spreadsheet API to inspect and sanitize Excel documents (remove sensitive or hidden content). You can process the predefined sample file or supply your own document. To do the latter, select Upload a File in the file selection drop-down menu.
Select hidden content to remove in the Remove Hidden Content section (Rows, Columns, Sheets, Invisible Cell Text). Select sensitive content to remove in the Remove Sensitive Content section (Metadata, Comments, Custom XML Parts, ActiveX Content, Macros, OLE Objects, Threaded Comments).
Select the operation type (Inspect or Sanitize) from the drop-down menu and click the button to process the document and download the result.
Select a Document
InvestmentPortfolio.xlsx
Sanitize Settings
Rows
Columns
Sheets
Invisible Cell Text
Metadata
Comments
Custom XML Parts
ActiveX Content
Macros
OLE Objects
Threaded Comments
using DevExpress.Spreadsheet;
using DevExpress.Office;
using System.Text;
string InspectWorkbook(Stream inputStream, WorkbookInspectOptions inspectOptions) {
using var workbook = new Workbook();
workbook.LoadDocument(inputStream);
StringBuilder output = new StringBuilder();
var inspectResult = workbook.Inspect(inspectOptions);
if(inspectResult.ContentTypes.Count == 0) {
output.AppendLine("No issues found.");
}
else {
output.AppendLine("Document contains the following hidden/sensitive content:");
output.AppendLine(string.Join(Environment.NewLine, inspectResult.ContentTypes));
}
return output.ToString();
}
Stream SanitizeWorkbook(Stream inputStream, DocumentFormat outputFormat, WorkbookSanitizeOptions sanitizeOptions = null) {
using var workbook = new Workbook();
workbook.LoadDocument(inputStream);
// Inspect a document and create WorkbookSanitizeOptions based on the inspection result
if(sanitizeOptions == null) {
var inspectResult = workbook.Inspect();
sanitizeOptions = inspectResult.CreateSanitizeOptions();
}
// Use the sanitizeResult object to get information about the removed content
var sanitizeResult = workbook.Sanitize(sanitizeOptions);
// Save document
var outputStream = new MemoryStream();
workbook.SaveDocument(outputStream, outputFormat);
outputStream.Position = 0;
return outputStream;
}