__init__ constructor

On this page

init

Initializes a new CellColumnRedaction.

def __init__(self, filter, reg_ex, options):
    ...
Parameter Type Description
filter CellFilter Column and worksheet filter.
reg_ex System.Text.RegularExpressions.Regex Regular expression to search and replace.
options ReplacementOptions Replacement options.

Example

from groupdocs.redaction import Redactor
from groupdocs.redaction.redactions import CellColumnRedaction, ReplacementOptions
from groupdocs.redaction.redactions import CellFilter

# Define a filter for column 2 in the first worksheet
cell_filter = CellFilter()
cell_filter.column_index = 2
cell_filter.work_sheet_name = "Sheet1"

# Create a redaction that replaces matches of the regex with a placeholder
redaction = CellColumnRedaction(
    cell_filter,
    r"\bsecret\b",
    ReplacementOptions("[REDACTED]")
)

with Redactor("spreadsheet.xlsx") as redactor:
    redactor.apply(redaction)
    redactor.save()

See Also

On this page