I'm trying to programatically read the contents of an Excel spreadsheet (.xlsm format) using the Microsoft.Jet.OLEDB.4.0** in C#.
My connection string is:
Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties="Excel 8.0;HDR=YES;IMEX=1;"";Data Source="C:\Test.xlsm"
When I execute my code, it fails with an exception stating:
OldDbException was unhandled by user code
External table is not in the expected format.
However - if I open the Test.xlsm file in Excel and re-run my code, it works with no exception and performs as intended. No problems, works great.
- Why/How does having a particular file open in Excel change how my code is accessing it?
- What is the correct way to open a .xlsm file with the Microsoft Jet OLEDB provider?
Additional Information: Running Windows 7 x64 / Excel 2010