XLS Import misses the first line of the xls sheet

donkeyballs

New member
Joined
Nov 23, 2010
Messages
1
Programming Experience
1-3
Not sure why but the below imports seems to miss off the first line of the sheet in the XLS file that this is reading in. Can't seem to find anyone else with this issue so I am guessing I have programmed this incorrectly, any help would be much appreciated.

VB.NET:
Dim filepath As String = Server.MapPath("~\uploads\Spec")
            filepath &= "\" & Me.fuspec.FileName.ToString
            Me.fuspec.SaveAs(filepath)
            '2) Import XLS
            Dim sConnectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
                "Data Source=" & filepath & ";Extended Properties=""Excel 12.0 Xml;"""

            Dim TmpString As String = GetExcelSheetNames(filepath)
            ' Create the connection object by using the preceding connection string.
            Dim objConn As New OleDbConnection(sConnectionString)
            ' Open connection with the database.
            objConn.Open()
            ' The code to follow uses a SQL SELECT command to display the data from the worksheet.
            ' Create new OleDbCommand to return data from worksheet.
            Dim objCmdSelect As New OleDbCommand("SELECT * FROM [" & TmpString & "]", objConn)
            'Dim objCmdSelect As New OleDbCommand("SELECT * FROM [Sheet1$]", objConn)

            ' Create new OleDbDataAdapter that is used to build a DataSet 
            ' based on the preceding SQL SELECT statement.
            Dim objAdapter1 As New OleDbDataAdapter()
            ' Pass the Select command to the adapter.
            objAdapter1.SelectCommand = objCmdSelect
            ' Create new DataSet to hold information from the worksheet.
            Dim objDataset1 As New DataSet()
            ' Fill the DataSet with the information from the worksheet.
            objAdapter1.Fill(objDataset1, "XLData")
 
Back
Top