CellColumnRedaction

CellColumnRedaction class

Represents a text redaction that replaces text in a spreadsheet documents (CSV, Excel, etc.).

public class CellColumnRedaction : TextRedaction

Constructors

Name Description
CellColumnRedaction(CellFilter, Regex, ReplacementOptions) Initializes a new instance of CellColumnRedaction class.

Properties

Name Description
ActionOptions { get; } Gets the ReplacementOptions instance, specifying type of text replacement.
override Description { get; } Returns a string, describing the redaction and its parameters.
Filter { get; } Gets the column and worksheet filter.
OcrConnector { get; set; } Gets or sets the IOcrConnector implementation, required to extract text from graphic content.
Pattern { get; } Gets the regular expression to match.

Methods

Name Description
override ApplyTo(DocumentFormatInstance) Applies the redaction to a given format instance.

Remarks

Learn more

Examples

The following example demonstrates removing user emails from a second column on “Customers” worksheet of a spreadsheet document.

using (Redactor redactor = new Redactor("D:\\Sales in September.xslx"))
{
   var filter = new CellFilter()
   {
       ColumnIndex = 1, // zero-based 2nd column
       WorkSheetName = "Customers"
   };
   var expression = new Regex("^\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$");
   RedactorChangeLog changeLog = redactor.Apply(new CellColumnRedaction(filter, expression, new ReplacementOptions("[customer email]")));
   if (result.Status != RedactionStatus.Failed)
   {
      doc.Save(new SaveOptions() { AddSuffix = true });
   };
}

See Also