CellColumnRedaction
Inheritance: java.lang.Object, com.groupdocs.redaction.Redaction, com.groupdocs.redaction.redactions.TextRedaction
public class CellColumnRedaction extends TextRedaction
Represents a text redaction that replaces text in a spreadsheet documents (CSV, Excel, etc.).
Learn more
- More details about applying redactions: Redaction basics
- More details about spreadsheet redactions: Spreadsheet redactions
The following example demonstrates removing user emails from a second column on “Customers” worksheet of a spreadsheet document.
try (Redactor redactor = new Redactor("D:\\Sales in September.xslx"))
{
CellFilter filter = new CellFilter();
filter.setColumnIndex(1); // zero-based 2nd column
filter.setWorkSheetName("Customers");
Pattern expression = Pattern.compile("^\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$");
RedactorChangeLog changeLog = redactor.apply(new CellColumnRedaction(filter, expression, new ReplacementOptions("[customer email]")));
if (result.Status != RedactionStatus.Failed)
{
SaveOptions opt = new SaveOptions();
opt.setAddSuffix(true);
doc.save(opt);
};
}
Constructors
Constructor | Description |
---|---|
CellColumnRedaction(CellFilter filter, Pattern regEx, ReplacementOptions options) | Initializes a new instance of CellColumnRedaction class. |
Methods
Method | Description |
---|---|
getPattern() | Gets the regular expression to match. |
getFilter() | Gets the column and worksheet filter. |
getDescription() | Returns a string, describing the redaction and its parameters. |
applyTo(DocumentFormatInstance formatInstance) | Applies the redaction to a given format instance. |
CellColumnRedaction(CellFilter filter, Pattern regEx, ReplacementOptions options)
public CellColumnRedaction(CellFilter filter, Pattern regEx, ReplacementOptions options)
Initializes a new instance of CellColumnRedaction class.
Parameters:
Parameter | Type | Description |
---|---|---|
filter | CellFilter | Column and worksheet filter |
regEx | java.util.regex.Pattern | Regular expression to search and replace |
options | ReplacementOptions | Replacement options |
getPattern()
public final Pattern getPattern()
Gets the regular expression to match.
Returns: java.util.regex.Pattern - The regular expression to match.
getFilter()
public final CellFilter getFilter()
Gets the column and worksheet filter.
Returns: CellFilter - The column and worksheet filter.
getDescription()
public String getDescription()
Returns a string, describing the redaction and its parameters.
Returns: java.lang.String - Text, containing redaction name and parameters.
applyTo(DocumentFormatInstance formatInstance)
public RedactorLogEntry applyTo(DocumentFormatInstance formatInstance)
Applies the redaction to a given format instance.
Parameters:
Parameter | Type | Description |
---|---|---|
formatInstance | DocumentFormatInstance | An instance of a document to apply redaction |
Returns: RedactorLogEntry - Status of the redaction: success/failure and error message if any