Created
August 8, 2024 13:27
-
-
Save conholdate-gists/1cecd45f503cb336f633be0d4cda2a2b to your computer and use it in GitHub Desktop.
Redact Excel Files in C# | Excel XLSX Redaction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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