Search code examples
c#excelepplus

EPPlus & Data Comparison


I am running a C# project with EPPlus libraries , I need it to check cells for data in various columns/rows and then find "keywords" so to speak and match it to data found in other various columns/rows.

I need to know a method for comparing data in a cell with data from another cell and finding a match.

The user selects an excel workbook & sheet through the gui , then runs this

Loop for checking cell data.

Variables.rowCount = Variables.worksheet.Dimension.End.Row;

for (i = 1; i <= Variables.rowCount; i++)
{
    Variables.cellValue = Variables.worksheet.Cells[i, 1].Text;
    Variables.cellValue1 = Variables.worksheet1.Cells[i, 1].Text;
    //...

Essentially I need it to do what Excel does when you select a filter and choose contains "word".

I hope I have explained this correctly.


Solution

  • have a look at this example:

    if (worksheet.Cells[i, 1].Value.ToString().Contains("word"))

    this gets the value of the cell and compares it with the search string