title: search for text in excel file c#
body: <p>I'm writing a windows application with c# and in one form I want to use a n excel file in this way.</p>
  
  <p>In the form when the user types the Employee ID in a text box I wanna search the excel file and based on the ID show other information for the employee in some other text boxes(name text box, last name text box ,status textbox ,and food count text box)</p>
  
  <p>please tell me how can I retrieve the info from it .</p>
  
  <pre><code>public List &lt;string&gt;[] RetrieveColumnGeneral(Excel.Worksheet sheet,string FindWhat)
      {
          int columnCount = sheet.UsedRange.Columns.Count;
          List&lt;string&gt;[] columnValue = new List&lt;string&gt;[columnCount];
          Excel.Range rngResult = null;
          Excel.Range rng = null;
  
          int index = 0;
          int rowCount = sheet.UsedRange.Rows.Count;
          Excel.Range FindRange = null;
          for (int columnIndex = 1; columnIndex &lt;= sheet.UsedRange.Columns.Count;columnIndex++ )
          {
              FindRange = sheet.UsedRange.Columns[columnIndex] as Excel.Range;
              FindRange.Select();
              rngResult = FindRange.Find(What: FindWhat, LookIn: Excel.XlFindLookIn.xlValues,
                  LookAt: Excel.XlLookAt.xlPart, SearchOrder: Excel.XlSearchOrder.xlByRows);
              if (rngResult != null)
              {
                  columnValue[index] = new List&lt;string&gt;();
  
                  for (int rowIndex = 1; rowIndex &lt;= sheet.UsedRange.Rows.Count;rowIndex++ )
                  {
                      rng = sheet.UsedRange[rowIndex, columnIndex] as Excel.Range;
                      if (rng.Value != null)
                      {
                          columnValue[index].Add(rng.Value.ToString());
                      }
                  }
                  index++;
              }
          }    
          Array.Resize ( ref columnValue , index);
          return columnValue;
      }
  </code></pre>
  
  <p>thanks I found this code . Will you tell me whether this will solve my problem ?(also by some modifications.)</p>