使用EPPLUS查找和替换所有字符串(Find and Replace all string using EPPLUS)
var valueToSearch = "Foo"; var valueToReplace = "Bar"; var sheetName = "Sheet1"; var filePath = @"d:\foo-bar.xlsx"; using (var excel = new ExcelPackage(new System.IO.FileInfo(filePath))) { var ws = excel.Workbook.Worksheets[sheetName]; // search in all cells // https://github.com/JanKallman/EPPlus/wiki/Addressing-a-worksheet var query = from cell in ws.Cells["A:XFD"] where cell.Value?.ToString().Contains(valueToSearch) == true select cell; foreach(var cell in query) { cell.Value = cell.Value.ToString().Replace(valueToSearch, valueToReplace); } excel.Save(); }
https://stackoverflow.com/questions/56312166/find-and-replace-all-string-using-epplus
浙公网安备 33010602011771号