非常着急
EXCEL表里有一个EXCEL 字段:
车牌
A001K6
A001K7
A001L0
A001L6
A002J2
A002K1
A002K2
打开代码如下: //ADOsource1为adoconnection, qrysource1为adoquery;
AdoSource1.Connected:=false;//多次打开出错问题
EdtSource.Text:=OPD.FileName;
AdoSource1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0 '
+';Data Source='+EdtSource.Text
+';Extended Properties=Excel 8.0 '
+';Persist Security Info=False '; AdoSource1.LoginPrompt:=False;
//Ls:=TStringList.Create;
// AdoSource1.GetTableNames(Ls,false); try
AdoExcute.Execute('drop table source1')
except
;;
end;
with QrySource1 do
begin
Close;
SQL.Clear;
SQL.text:='Select distinct * from [sheet1$] in '
+'"'+EdtSource.Text +'" "Excel 8.0;hdr=yes;imex=1"';
open;
end;
EXCEL表里有一个EXCEL 字段:
车牌
A001K6
A001K7
A001L0
A001L6
A002J2
A002K1
A002K2
打开代码如下: //ADOsource1为adoconnection, qrysource1为adoquery;
AdoSource1.Connected:=false;//多次打开出错问题
EdtSource.Text:=OPD.FileName;
AdoSource1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0 '
+';Data Source='+EdtSource.Text
+';Extended Properties=Excel 8.0 '
+';Persist Security Info=False '; AdoSource1.LoginPrompt:=False;
//Ls:=TStringList.Create;
// AdoSource1.GetTableNames(Ls,false); try
AdoExcute.Execute('drop table source1')
except
;;
end;
with QrySource1 do
begin
Close;
SQL.Clear;
SQL.text:='Select distinct * from [sheet1$] in '
+'"'+EdtSource.Text +'" "Excel 8.0;hdr=yes;imex=1"';
open;
end;
解决方案 »
- 使用SendMessage 模拟鼠标点击
- 高手!问题是这样的。
- a + b + c + d -e-f 的 逆波兰式是怎样的?
- ShellListView
- 各位高手,请问为何DBChart连接Access库时,不能显示文本字段,只显示数字型字段?
- 关于finger的问题。
- 怎样在Delphi6上发布一个基于BDE的数据库应用程序?
- 我在一个窗体上调用另一个窗体(使用的是在uses 里加入另一个窗体的文件名 )但我需要在另一个窗体修改调用它窗体的控件的属性!这怎么做
- 如何写回车就可以默认确定组件被击中的代码/
- 重发delphi5中怎样调用TWAIN32.DLL来扫描图像?
- 关于ListControl控件的问题
- Windows服务程序里使用IdUdpServer
A001K6?
A001K7
A001L0
A001L6?
A002J2
A002K1
A002K2
哪位碰到过类似问题啊.解决一下吧..
EdtSource.Text:=OPD.FileName;
AdoSource1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0 '
+';Data Source='+EdtSource.Text
+';Extended Properties=Excel 8.0 '
+';Persist Security Info=False ';
AdoSource1.LoginPrompt:=False;
with QrySource1 do
begin
Close;
SQL.Clear;
SQL.text:='Select distinct * from [sheet1$] in '
+'"'+EdtSource.Text +'" "Excel 8.0;hdr=yes;imex=1"';
open;
end;
就是用以上代码打开的,现在简化了,但是仍然会用乱码..
http://hi.baidu.com/lingyin55/blog/category/delphi%B6%D4office%B5%C4%B2%D9%D7%F7是不是你的excel里面有其它的内容?或者是类型的问题?
begin
opendialog1.Execute;
adoconnection1.Close;
adoconnection1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;'
+'Data Source='+opendialog1.FileName+';'
+'Extended Properties=excel 8.0;'
+'Persist Security Info=False';
with adoquery1 do
begin
Close;
SQL.Clear;
sQL.Text:='Select * from [sheet1$]';
open;
end;
end; end.
在bitbtn里面添加这段代码就行了,adoconnection里面不需要设置,adoquery,datasource,dbgrib自己关联下就ok了