The following sample code gives an idea to use enterprise library:
String path = @"filepath";
String ConnectionString = @"Data Source=" + path + ";Provider=Microsoft.ACE.OLEDB.12.0; Extended Properties=Excel 12.0;";
DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.OleDb");
using (DbConnection connection = factory.CreateConnection())
{
connection.ConnectionString = ConnectionString;
using (DbCommand command = connection.CreateCommand())
{
connection.Open();
command.CommandText = "SELECT * FROM [Sheet1$]"; //Sheet1 here is the name of the sheet which is to be read
using (DbDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
}
}
}
}