Delphi7使用ADO直接连接Excel读取数据

时间:2023-03-09 19:06:50
Delphi7使用ADO直接连接Excel读取数据

我之前是连接成功的,现在不知道为什么怎样连都失败。最后才知道是Office版本的问题,office2007已经是基于xml的。和以前的不一样。

Excel2003的连接字符串:

'Provider=Microsoft.Jet.OLEDB.4.0;Password="";Data Source=' + sFileName + ';Extended Properties=Excel 8.0;Persist Security Info=True';

Excel2007的连接字符串:

'Provider=Microsoft.ACE.OLEDB.12.0;Password="";Data Source=' + sFileName+';Extended Properties=''Excel 12.0;IMEX=1;HDR=YES'';Persist Security Info=True;';