0

I can easily open xls file with this code:

System.Data.OleDb.OleDbConnection theConnection = new System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;data source=C:\\Users\\us269229\\Desktop\\workbook.xls;Extended Properties=\"Excel 8.0;HDR=NO;IMEX=1;\"");
theConnection.Open();

however, I cannot open xlsx files. With the above code I get the following error:

External table is not in the expected format.

so I tried the following if the extension is xlsx:

System.Data.OleDb.OleDbConnection theConnection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\us269229\\Desktop\\workbook.xlsx;" + "Extended Properties=\"Excel 12.0 Xml;HDR=YES\"");

theConnection.Open();

however, with this I get this error:

The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.

I did download and install AccessDatabaseEngine_X64.exe, but this did not clear my error.

Any help would be appreciated - thanks in advance

RBarryYoung
  • 55,398
  • 14
  • 96
  • 137
Naomi
  • 27
  • 3

1 Answers1

0

I think you need to Install "The 2007 Office System Driver: Data Connectivity Components.".

Source: 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine

Param
  • 1