findAndReplace method
Returns the count of replaced source with target
source is dynamic which allows you to pass your custom RegExp providing more control over it.
optional argument first is used to replace the number of first earlier occurrences
If first is set to 3 then it will replace only first 3 occurrences of the source with target.
excel.findAndReplace('MySheetName', 'sad', 'happy', first: 3);
or
var mySheet = excel['mySheetName'];
mySheet.findAndReplace('MySheetName', 'sad', 'happy', first: 3);
In the above example it will replace all the occurences of sad with happy in the cells
Other options are used to narrow down the starting and ending ranges of cells.
Implementation
int findAndReplace(String sheet, dynamic source, dynamic target,
{int first = -1,
int startingRow = -1,
int endingRow = -1,
int startingColumn = -1,
int endingColumn = -1}) {
int replaceCount = 0;
if (_sheetMap[sheet] == null) return replaceCount;
_sheetMap['$sheet']!.findAndReplace(
source,
target,
first: first,
startingRow: startingRow,
endingRow: endingRow,
startingColumn: startingColumn,
endingColumn: endingColumn,
);
return replaceCount;
}