// Open the file you want to clean
final Redactor redactor = new Redactor("source.xslx");
try
{
// Create an EMAIL regex pattern and set replacement text
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);
// Run the redaction process
redactor.apply(redaction);
// Save the updated version
SaveOptions saveOptions = new SaveOptions();
saveOptions.setAddSuffix(true);
saveOptions.setRasterizeToPDF(false);
redactor.save(saveOptions);
}
finally { redactor.close(); }