Table of Contents

Method ReplaceText

Namespace
DocWright.Formats.Xlsx
Assembly
DocWright.Formats.Xlsx.dll

ReplaceText(string, string, XlsxFindOptions?)

Replaces every occurrence of a text in the sheet's cells.

public XlsxReplaceResult ReplaceText(string text, string replacement, XlsxFindOptions? options = null)

Parameters

text string

The text to find.

replacement string

What to put in its place. Taken literally.

options XlsxFindOptions

How to match, or null for the defaults.

Returns

XlsxReplaceResult

What was replaced, and the cells that held a match and were left alone, with the reason for each.

Remarks

A cell that is changed is written as plain text in the cell's format: text that was formatted in parts (rich text) loses the parts. A formula's result is never replaced (that would turn the formula into a constant); with Formulas the formula's own text is.

Exceptions

ArgumentNullException

text or replacement is null.

ArgumentException

text is empty.

InvalidDocumentException

The sheet's part is malformed.