Hi all,
I want to import excel data in to web form gridview . I can run it on my PC ( vs 2019 + win 10 + office 2010) . But can't run at windows 2016 server (no office).
Is it possible not to install office and run these codes ?
Thank you so much.
Protected Sub Excel_To_GridView2()
Try
Dim fileName As String = Server.HtmlEncode(ExcelUpload.FileName)
Dim strConn As String = "Provider = Microsoft.ACE.OLEDB.12.0;Data Source=D:\Temp inport files\" & fileName & ";Extended Properties='Excel 12.0;HDR=YES'"
'MsgBox(strConn)
Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM [Sheet1$]", strConn)
Dim ds As DataSet = New DataSet
da.Fill(ds, "dw")
Me.GridView2.DataSource = ds
Me.GridView2.DataMember = "dw"
Me.GridView2.DataBind()
Catch ex As Exception
WebMessageBox(Me.Page, ex.Message)
'MsgBox(ex.Message)
End Try
End Sub