Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save aspose-com-gists/bbb6f03f1f8945472afb885763e97437 to your computer and use it in GitHub Desktop.
Find and Replace Text in Excel - Aspose.Cells for .NET
// Load Excel workbook
Workbook workbook = new Workbook("Excel.xlsx");
ReplaceOptions replace = new ReplaceOptions();
// Set case sensitivity and text matching options
replace.CaseSensitive = false;
replace.MatchEntireCellContents = false;
// Set RegexKey to true to indicate that the searched key is a Regex
replace.RegexKey = true;
// Replace text
workbook.Replace("\\bKIM\\b", "^^^TIM^^^", replace);
// Save updated Excel workbook
workbook.Save("Updated Excel.xlsx");
// Load Excel workbook
Workbook workbook = new Workbook("Excel.xlsx");
ReplaceOptions replace = new ReplaceOptions();
// Set case sensitivity and text matching options
replace.CaseSensitive = false;
replace.MatchEntireCellContents = false;
// Replace text
workbook.Replace("find and replace this text","with this text", replace);
// Save updated Excel workbook
workbook.Save("Updated Excel.xlsx");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment