Click here to Skip to main content
15,881,690 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have one .xlsm file to read in my project. This is my connection string used:

VB
If strExtension = ".xls" Then
                    MyConnection = New System.Data.OleDb.OleDbConnection _
                "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strFilePath & ";Extended Properties=""Excel 8.0;IMEX=1;;HDR=YES""")
                ElseIf strExtension = ".xlsx" Then
                    MyConnection = New System.Data.OleDb.OleDbConnection _
                    ("provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & strFilePath & ";Extended Properties=""Excel 12.0;IMEX=1;;HDR=YES""")
                ElseIf strExtension = ".xlsm" Then
                    MyConnection = New System.Data.OleDb.OleDbConnection _
                    ("provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & strFilePath & ";Extended Properties=""Excel 12.0 Macro;IMEX=1;;HDR=YES""")
                End If

VB
Dim MyCommand As OleDbCommand = New OleDbCommand _
                    ("select * from [UserDetails$]", MyConnection)

                Dim dsChangedValues As New DataSet()
                Dim obj As OleDbDataAdapter = New OleDbDataAdapter(MyCommand)
                obj.Fill(dsChangedValues)



It works fine if I am uploading a .xlsx file. But I have to upload a .xlsm file.
Its giving 'External table not in the expected format' exception in the
obj.Fill(dsChangedValues) line. :(

Any solutions?

Thanks in advance..
Ami
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900