Method ReplaceText
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
textstringThe text to find.
replacementstringWhat to put in its place. Taken literally.
optionsXlsxFindOptionsHow 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
textorreplacementis null.- ArgumentException
textis empty.- InvalidDocumentException
The sheet's part is malformed.