Table of Contents

Method ReplaceText

Namespace
DocWright.Spreadsheet
Assembly
DocWright.Spreadsheet.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 keeps its format; text formatted in parts (rich text) keeps its runs, and a replacement takes the format of the run it starts in (Phase 205). A number is replaced in the text it shows and stays a number when the result still reads as one (SearchNumbers). 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.