Hi Arun,
first load excel sheet into dataset and find text in dataset.
use below sample code to load excel to dataset:
public void LoadallAttributions(string filePath)
{
IExcelDataReader excelReader = null;
DataSet result = new DataSet();
FileStream stream = null;
try
{
stream = File.Open(filePath, FileMode.Open, FileAccess.Read);
if (String.Compare(Path.GetExtension(filePath), ".xls", true) == 0)
excelReader = ExcelReaderFactory.CreateBinaryReader(stream);
else if (String.Compare(Path.GetExtension(filePath), ".xlsx", true) == 0)
excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
if (excelReader != null)
{
excelReader.IsFirstRowAsColumnNames = true;
result = excelReader.AsDataSet();
dataset = result;
}
}
catch (Exception ex)
{
MessageBox.Show(Path.GetFileName(filePath).ToString() +" file opened out side the application, please close and try again.");
}
finally
{
excelReader.Close();
excelReader.Dispose();
if (stream != null)
{
stream.Close();
stream.Dispose();
}
}
}