I want to be able to find if a particular string exists in a range using ClosedXML, however, I cannot find any find command in the documentation. Currently I loop through 1000s of rows to find if the string exists. Is there a more efficient way to do this?
Here is an example of my code:
for (int j = 3; j <= PipeSheet.LastRowUsed().RowNumber(); j ++)
{
if ((PipeSheet.Cell(j, ProdCodeColumnInPipe).Value.ToString().Trim() == SheetToEdit.Cell(i, ProdCodeColumnInMain).Value.ToString().Trim() & PipeSheet.Cell(j, 3).Value.ToString().Trim() == SheetToEdit.Cell(i, RegionCodeInMain).Value.ToString().Trim()))
{
SheetToEdit.Cell(i, ColumnToEdit).Value = "+";
if ((new[] { "Open", "Under Review" }).Contains(PipeSheet.Cell(j, 5).Value.ToString().Trim()) & (new[] { "Forecast"}).Contains(PipeSheet.Cell(j, 4).Value.ToString().Trim()))
{
if (FirstColumnHighlight > 1 & LastColumnHighlight > 1)
{
for (int k = FirstColumnHighlight; k <= LastColumnHighlight; k++)
{
SheetToEdit.Cell(i, k).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 0);
}
}
}
}
}