Then data is read from the sheet and returned as dataset
Protected Function ExcelConnection() As DataSet
Dim xConnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("Uploads/ExcelFile.xls") & ";" & _
"Extended Properties=""Excel 8.0; IMEX=1;"""
Dim objXConn As New OleDbConnection(xConnStr)
objXConn.Open()
Dim dsExcelData As New DataSet
Dim objCommand As New OleDbCommand("SELECT * FROM [Sheet1$]", objXConn)
Dim objAdapter As New OleDbDataAdapter
objAdapter.SelectCommand = objCommand
objAdapter.Fill(dsExcelData)
objAdapter.Dispose()
objCommand.Dispose()
objXConn.Close()
Return dsExcelData
End Function
Dim xConnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("Uploads/ExcelFile.xls") & ";" & _
"Extended Properties=""Excel 8.0; IMEX=1;"""
Dim objXConn As New OleDbConnection(xConnStr)
objXConn.Open()
Dim dsExcelData As New DataSet
Dim objCommand As New OleDbCommand("SELECT * FROM [Sheet1$]", objXConn)
Dim objAdapter As New OleDbDataAdapter
objAdapter.SelectCommand = objCommand
objAdapter.Fill(dsExcelData)
objAdapter.Dispose()
objCommand.Dispose()
objXConn.Close()
Return dsExcelData
End Function
A Number Of Different Approaches Are Being Tried We're still guessing.
No comments:
Post a Comment