How to make search and display multiple values from excel?

Good day, friends.

How to write a loop search through column in excel file and display it?

At the moment there is code that searches the file for a specific column, but finds and displays only the first value. And to continue and display everything?

private void Button_search_Click(object sender, EventArgs e) // search Button
{
 Microsoft.Office.Interop.Excel.Application ObjExcel = new Microsoft.Office.Interop.Excel.Application();
 Microsoft.Office.Interop.Excel.Workbook ObjWorkBook = ObjExcel.Workbooks.Open("C:\\SDH\\temp\\templates_sm_tech.xlsx", 0, false, 5, "", "", false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);
 Microsoft.Office.Interop.Excel.Worksheet ObjWorkSheet;
 ObjWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)ObjWorkBook.Sheets[1];

 string take = textBox_search.Text; //Search the cells

 Microsoft.Office.Interop.Excel.Range range = ObjWorkSheet.get_Range("M:M").Find(take);

 if (Convert.ToString(range.Value) != null)
{
 label_opertime.Text = "Time for operation:" + "" + ObjWorkSheet.get_Range("E" + range.Row.ToString()).Value2 + "" + "mins";
 textBox_ac.Text = ObjWorkSheet.get_Range("B" + range.Row.ToString()).Value2; // AC
 textBox_group.Text = ObjWorkSheet.get_Range("I" + range.Row.ToString()).Value2; // the working group
 label_type.Text = ObjWorkSheet.get_Range("A" + range.Row.ToString()).Value2; // hit Type
 textBox_finish.Text = ObjWorkSheet.get_Range("K" + range.Row.ToString()).Value2 + System.Environment.NewLine + "/// the solution Code: "+ ObjWorkSheet.get_Range("L" + range.Row.ToString()).Value2 + " ///"; // Solution

}
else
{
 MessageBox.Show("Nothing found! Try to change the query and try again.");
}

ObjExcel.Quit();
ObjExcel.Application.Quit();
 }
April 3rd 20 at 18:48
1 answer
April 3rd 20 at 18:50
Solution

Find more questions by tags C#