// Open the file to process
final Redactor redactor = new Redactor("source.xlsx");
try
{
// Add an EMAIL regex rule and replacement
ReplacementOptions repl_opt = new ReplacementOptions("[redacted]");
String emailRegex = "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}";
RegexRedaction redaction = new RegexRedaction(emailRegex, repl_opt);
// Apply redaction rules
redactor.apply(redaction);
// Save the updated file
SaveOptions saveOptions = new SaveOptions();
saveOptions.setAddSuffix(true);
saveOptions.setRasterizeToPDF(false);
redactor.save(saveOptions);
}
finally { redactor.close(); }