title: Import Excel to Datagridview
body: <p>I'm trying to import a data set from Excel to a DB with VB.net. With this code I always get the error</p>
  
  <blockquote>
    <p>External table is not in the expected format.</p>
  </blockquote>
  
  <pre><code>Imports Excel = Microsoft.Office.Interop.Excel
  Imports Microsoft.Office
  Imports Microsoft.Office.Interop
  Imports System.IO
  Imports System.Data.SqlClient 
  
  Private Sub Button_Import_Click(sender As Object, e As EventArgs) Handles Button_Import.Click
      Try
          Dim MyConnection As OleDb.OleDbConnection
          Dim Ds As System.Data.DataSet
          Dim MyAdapter As System.Data.OleDb.OleDbDataAdapter
          MyConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\Users\matil\Desktop\Data.xlsx';Extended Properties=Excel 8.0;")
          MyAdapter = New System.Data.OleDb.OleDbDataAdapter("Select * from [ExportedFromDatGrid$]", MyConnection)
          Ds = New System.Data.DataSet
          MyAdapter.Fill(Ds)
          Me.DataGridView_Kontakte.DataSource = Ds.Tables(0)
      Catch ex As Exception
          MsgBox(ex.Message)
      End Try
  End Sub
  </code></pre>
  
  <p>My DB looks like this
  <a href="https://i.stack.imgur.com/avtM9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/avtM9.png" alt="enter image description here"></a></p>
  
  <p>and my Excel File like this
  <a href="https://i.stack.imgur.com/SWGmk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SWGmk.png" alt="enter image description here"></a></p>