Skip to content

Instantly share code, notes, and snippets.

@conholdate-gists
Created August 8, 2024 13:27
Show Gist options
  • Save conholdate-gists/1cecd45f503cb336f633be0d4cda2a2b to your computer and use it in GitHub Desktop.
Save conholdate-gists/1cecd45f503cb336f633be0d4cda2a2b to your computer and use it in GitHub Desktop.
Redact Excel Files in C# | Excel XLSX Redaction
using (GroupDocs.Redaction.Redactor redactor = new GroupDocs.Redaction.Redactor("SalesSeptember.xlsx"))
{
var filter = new GroupDocs.Redaction.Redactions.CellFilter()
{
ColumnIndex = 1, // zero-based 2nd column
WorkSheetName = "Customers"
};
var expression = new System.Text.RegularExpressions.Regex("^\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$");
GroupDocs.Redaction.RedactorChangeLog changeLog = redactor.Apply(new GroupDocs.Redaction.Redactions.CellColumnRedaction(filter, expression, new GroupDocs.Redaction.Redactions.ReplacementOptions("[customer email]")));
if (changeLog.Status != GroupDocs.Redaction.RedactionStatus.Failed)
{
redactor.Save(new GroupDocs.Redaction.Options.SaveOptions() { AddSuffix = true });
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment