VB.net read Excel 2007 and later

Hi

I am using the following VB.net code in my ASP.net web app to read an Excel 97 to 2003 .xls file. I want it to work with
2007 and later rather. What do I change?
Thanks


    Protected Function ExcelConnection() As OleDbCommand
        Try

            ' Connect to the Excel Spreadsheet
            'Dim xConnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
            '"Data Source=" & Server.MapPath("~/ExcelImport.xls") & ";" & _
            '"Extended Properties=Excel 8.0;"

            Dim sMinAndSecond As String = Me.Second_Minute_of_Upload.Text 'workaround to stop file locking on the same name


            Dim xConnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
            "Data Source=" & Server.MapPath("~/Temp/ExcelImport" & sMinAndSecond & ".xlsx") & ";" & _
            "Extended Properties=""Excel 8.0;HDR=YES;IMEX=1"""


            ' create your excel connection object using the connection string
            Dim objXConn As New OleDbConnection(xConnStr)
            objXConn.Open()

            ' use a SQL Select command to retrieve the data from the Excel Spreadsheet
            ' the "table name" is the name of the worksheet within the spreadsheet
            ' in this case, the worksheet name is "Members" and is expressed as: [Members$]
            Dim objCommand As New OleDbCommand("SELECT * FROM [Sheet1$]", objXConn)
            Return objCommand
        Catch ex As Exception
            Response.Write("There was an error connecting to the Excel spreadsheet! " & Err.Description & " xk6")
        End Try

    End Function

Open in new window

Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
HI,

pls try

            Dim xConnStr As String = "Provider=Microsoft.Jet.OLEDB.12.0;" & _
            "Data Source=" & Server.MapPath("~/Temp/ExcelImport" & sMinAndSecond & ".xlsx") & ";" & _
            "Extended Properties=""Excel 12.0 Xml;HDR=YES;IMEX=1"""

Open in new window

Regards

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.