Public Function ReadExcel(filePath As [String], sheetName As [String]) As DataSet
Try
sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & Convert.ToString(filePath) & ";" & "Extended Properties=Excel 8.0;"
objConn = New System.Data.OleDb.OleDbConnection(sConnectionString)
objConn.Open()
tran = objConn.BeginTransaction()
Dim objCmdSelect As New System.Data.OleDb.OleDbCommand("SELECT * FROM [" & Convert.ToString(sheetName) & "$]", objConn)
objCmdSelect.Transaction = tran
Dim objAdapter1 As New System.Data.OleDb.OleDbDataAdapter()
objAdapter1.SelectCommand = objCmdSelect
Dim objDataset1 As New DataSet()
objAdapter1.Fill(objDataset1)
tran.Commit()
objConn.Close()
Return objDataset1
Catch
tran.Rollback()
Throw
Finally
objConn.Close()
End Try
End Function