Created
March 12, 2025 08:09
-
-
Save conholdate-gists/91aaedee92fe0b53588b70d5d83c2ef1 to your computer and use it in GitHub Desktop.
Redact Excel Worksheet in Java
This file contains hidden or 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
final com.groupdocs.redaction.Redactor redactor = new com.groupdocs.redaction.Redactor(dataDir + "SalesSeptember.xlsx"); | |
try | |
{ | |
com.groupdocs.redaction.redactions.CellFilter filter = new com.groupdocs.redaction.redactions.CellFilter(); | |
filter.setColumnIndex(1); | |
filter.setWorkSheetName("Customers"); | |
Pattern expression = Pattern.compile("^\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$"); | |
com.groupdocs.redaction.RedactorChangeLog result = redactor.apply(new com.groupdocs.redaction.redactions.CellColumnRedaction(filter, expression, new com.groupdocs.redaction.redactions.ReplacementOptions("[customer email]"))); | |
if (result.getStatus() != com.groupdocs.redaction.RedactionStatus.Failed) | |
{ | |
com.groupdocs.redaction.options.SaveOptions so = new com.groupdocs.redaction.options.SaveOptions(); | |
so.setAddSuffix(true); | |
so.setRasterizeToPDF(false); | |
redactor.save(so); | |
}; | |
} | |
finally { redactor.close(); } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment