1.use this name space:-Imports System.Globalization
2.Add the Excel file in Solution Explorer
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
fillgried()
End Sub
Function fillgrid()
Dim strConn As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Server.MapPath("Customers1.xlsx") + ";Extended Properties='Excel 12.0 Xml;HDR=YES;'"
Dim query As String = "SELECT * FROM [customers$]"
Dim excelDataSet As DataSet = New DataSet()
excelDataSet.Locale = CultureInfo.InvariantCulture
Dim da As OleDbDataAdapter = New OleDbDataAdapter(query, strConn)
da.Fill(excelDataSet)
GridView1.DataSource = excelDataSet.Tables(0)
GridView1.DataBind()
End Function
2.Add the Excel file in Solution Explorer
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
fillgried()
End Sub
Function fillgrid()
Dim strConn As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Server.MapPath("Customers1.xlsx") + ";Extended Properties='Excel 12.0 Xml;HDR=YES;'"
Dim query As String = "SELECT * FROM [customers$]"
Dim excelDataSet As DataSet = New DataSet()
excelDataSet.Locale = CultureInfo.InvariantCulture
Dim da As OleDbDataAdapter = New OleDbDataAdapter(query, strConn)
da.Fill(excelDataSet)
GridView1.DataSource = excelDataSet.Tables(0)
GridView1.DataBind()
End Function