Excel OLEDB - start row

Is there a way to specify a "start row" when using OLEDB to read an Excel file?  The code below works just fine if I have a header on line 1 and data starting on row 2.  However, my data will have miscellaneous information on lines 1 and 2, a header on line 3, and data starting on row 4.

Is there a way to indicate this in the Connection String?


    Dim ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=C:\test.xls;Extended Properties=""Excel 8.0;"""

    Dim cn As New OleDbConnection(ConnectionString)

    Dim ds As New DataSet

    Using cmd As New OleDbCommand("SELECT * FROM [Sheet1$]", cn)
        Dim da As New OleDbDataAdapter(cmd)
        da.Fill(ds, "Sheet1")
    End Using
Who is Participating?
DhaestConnect With a Mentor Commented:
I'm afraid you can't do that. The only thing (if I remember me correctly) is to tell if there is a header row or there is not. So you can't tell a connectionstring that a header-row is on line 3
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.