CellColumnRedaction
Leave feedback
On this page
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);
};
}
| Constructor | Description |
|---|---|
| CellColumnRedaction(CellFilter filter, Pattern regEx, ReplacementOptions options) | Initializes a new instance of CellColumnRedaction class. |
| 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. |
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 |
public final Pattern getPattern()
Gets the regular expression to match.
Returns: java.util.regex.Pattern - The regular expression to match.
public final CellFilter getFilter()
Gets the column and worksheet filter.
Returns: CellFilter - The column and worksheet filter.
public String getDescription()
Returns a string, describing the redaction and its parameters.
Returns: java.lang.String - Text, containing redaction name and parameters.
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
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.