Delphi ADO与Excel 2010或更新版本,与.RecordCount有关 [英] Delphi ADO with Excel 2010 or newer, problems with .RecordCount

查看:387
本文介绍了Delphi ADO与Excel 2010或更新版本,与.RecordCount有关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个例子,在这里我使用与ADO连接的excel文件,似乎可以与excel 2003文件,但是当我使用excel 2007或更新我收到一些问题接收记录计数..



我的连接字符串看起来像这样为excel 2003:

 格式('Provider = Microsoft.Jet.OLEDB .4.0;数据源=%s;扩展属性= Excel 8.0;',[filename])

和excel 2007或更新(xlsx文件)的相同的连接字符串

 格式('Provider = Microsoft.ACE.OLEDB.12.0;数据源=%s;扩展属性=Excel 12.0 Xml; HDR = YES; IMEX = 1',[文件名])

我需要更多的东西吗?或者我缺少允许使用记录计数,recno等等?

解决方案

看看这篇文章:
http://www.slxdeveloper.com/page.aspx? action = viewarticle& articleid = 33



基本上您需要将 CursorType 设置为 ctOpenForwardOnly


I have a case here where I use excel files connected with ADO, it seems OK with excel 2003 files, however when I use excel 2007 or newer I get some problems receiving recordcount..

my connection string look like this for excel 2003 :

format('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s;Extended Properties=Excel 8.0;',[filename])

and the same connectionstring for excel 2007 or newer (xlsx files)

format('Provider=Microsoft.ACE.OLEDB.12.0;Data Source=%s;Extended Properties="Excel 12.0 Xml;HDR=YES;IMEX=1"',[filename])

do I need something more here? or what am I missing to be allowed to use the recordcount, recno etc etc?

解决方案

Have a look at this article: http://www.slxdeveloper.com/page.aspx?action=viewarticle&articleid=33

Basically you need to set the CursorType to something other than ctOpenForwardOnly.

这篇关于Delphi ADO与Excel 2010或更新版本,与.RecordCount有关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆