ExcelFile.Find Method
Finds a value inside a cell and returns the position for the cell, or null if nothing was found.
Syntax
Namespace: FlexCel.Core
public abstract TCellAddress Find(Object value, TXlsCellRange Range, TCellAddress Start, Boolean ByRows, Boolean CaseInsensitive, Boolean SearchInFormulas, Boolean WholeCellContents)
Parameters
<-> | Parameter | Type | Description |
---|---|---|---|
value | Object | Value we are searching. | |
Range | TXlsCellRange | Range to Search. Null means the whole worksheet. | |
Start | TCellAddress | Cell where to start searching. For the first time, use null. After this, you can use the result of this method to get the next cell. | |
ByRows | Boolean | If true, the value will be searched down then left. If false, the search will go left then down. SEARCH IS FASTER WHEN BYROWS = FALSE | |
CaseInsensitive | Boolean | If true, string searches will not be case sensitive, "a" = "A" | |
SearchInFormulas | Boolean | If true, the search will cover formulas too. | |
WholeCellContents | Boolean | If true, the string must match the whole cell, not a part of it. |
Returns
Cell where the string is found, or null if it is not found.
Examples
To find all cells on a sheet that contain the string "bolts":
TCellAddress Cell = null; //initialize the value to null to start searching.
do
{
Cell = xls.Find("bolts", null, Cell, false, true, true, false); //find the next value.
if (Cell != null) LogMessage(Cell.CellRef);
}
while (Cell != null); //until it doesn't find any more matches.