Reputation: 3547
I have an excel file which have a column name (name
) which has the following entries:
I want to count the entries in the name
column where my string is "vipin"
. Using OLEDB data provider.
Upvotes: 0
Views: 2379
Reputation: 7308
Are you pulling the excel sheet into a DataTable like so?
OleDbDataAdapter cmd = new System.Data.OleDb.OleDbDataAdapter(
"select * from [" + worksheetName + "$]", con);
con.Open();
System.Data.DataSet excelDataSet = new DataSet();
cmd.Fill(excelDataSet);
con.Close();
If so just iterate through the DataRows like normal.
foreach(DataRow dataRow in excelDataSet.Tables[0].Rows){
if(dataRow["columnName"].ToString().Equals("vipin")){
count++;
}
}
Upvotes: 2