Skip to content

Instantly share code, notes, and snippets.

@conholdate-gists
Created March 12, 2025 08:09
Show Gist options
  • Save conholdate-gists/91aaedee92fe0b53588b70d5d83c2ef1 to your computer and use it in GitHub Desktop.
Save conholdate-gists/91aaedee92fe0b53588b70d5d83c2ef1 to your computer and use it in GitHub Desktop.
Redact Excel Worksheet in Java
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