Read .xlsx file

I'm trying to read .xlsx file and populate a DataTable.
I've added test.xlsx  file to the project.
Error: The Microsoft Office Access database engine could not find the object 'Sheet1'.  Make sure the object exists and that you spell its name and the path name correctly.

  <connectionStrings>
    <add name="xlsx" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=test.xlsx;Extended Properties=Excel 12.0"/>  
  </connectionStrings>

Private xlsx As String = ConfigurationManager.ConnectionStrings("xlsx").ConnectionString

Public Function GetData() as DataTable
 Dim dt As New DataTable
        Dim oleDbCon As New OleDbConnection(xlsx)
        oleDbCon.Open()
        Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM [Sheet1]", oleDbCon)
        Dim oleda As OleDbDataAdapter = New OleDbDataAdapter(cmd)
        oleda.Fill(dt)
oleDbCon.Close()
return dt
End Sub

Any help would be greatly appreciated!!
shahjagatAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:
Please try this

Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM Sheet1$", oleDbCon)

further more use connection string as
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=test.xlsx;Extended Properties=""Excel 12.0;HDR=Yes;IMEX=2"
0

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
lenordisteCommented:
as suggested by IJZ, what's important is the missing "$" at the end of the sheet name, so this would work also:
SELECT * FROM [Sheet1$]

Open in new window

0
Éric MoreauSenior .Net ConsultantCommented:
I prefer to use tools such as http://www.aspose.com/categories/.net-components/aspose.cells-for-.net/default.aspx to manipulate Excel files
0
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
.NET Programming

From novice to tech pro — start learning today.