How to Read Excel File using ASP.NET

Today I am Sharing Excel Reader to read Excel file from Asp.net C#.

This is database in Excel:

Image1.jpg

This is Codes:

using System;
using
System.Data;
using
System.Data.OleDb;

public
partial class ExcelReader : System.Web.UI.Page
{
    OleDbConnection olcon = new OleDbConnection(
@"Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data
Source=E:\exceldatareader\excelread\info.xlsx

;Mode=Share Deny Write;Extended Properties=""HDR=YES;"";Jet OLEDB:Engine Type=37"
);
    OleDbDataAdapter olda;

    protected void Page_Load(object sender, EventArgs e)
    {
       
try
        {
            olcon.Open();
            string query = "select [ID],[Name],[Business] from [Sheet1$]";
            olda = new OleDbDataAdapter(query, olcon);
            DataSet ds = new DataSet();
            olda.Fill(ds);
            GridView1.DataSource = ds;
            GridView1.DataBind();
        }
        catch (Exception ex)
        {
           Response.Write(ex.Message + ex.StackTrace); }
       
finally
        { olcon.Close(); }
    }
}

This is Result:

Image2.jpg