从delphi导数据到excel(从程序)太慢了,有没有更好的办法????
解决方案 »
- 怎么判断更改?
- 感谢大家几个月来对我的帮助,散掉所有可用分!
- 有一个程序A,一个COM组件B,我写的程序C,请问C如何监听A调用B的参数和返回值?
- 为什么不能将图片插入到DB2 7的BLOB字段?
- TTable中使用lookup语句进行查询后有没有返回值!
- teechart pro5 的正式版哪里有下,能用的话马上给分.
- 怎么做桌面精灵?
- 众位高手,小弟想问一下什么是I/O卡,它有什么用处,有没有专门介绍它的网站? 100分,请笑纳
- 哪有D5下載?
- UniQuery1想获得所有表名,代码该如何写?
- ADOConnection.ConnectionString如何动态改变?
- 一个关于怎样用ADSL Momden局域网上网的问题!
说清楚点儿!不是有许多相应的控件嘛!?
Dfn:=ExtractFileDir(application.ExeName)+'\reports\Êý¾Ýµ¼³öÄ£°å.xls'; opInfo.Wnd:=Handle;
opinfo.fAnyOperationsAborted:=false;
opInfo.lpszProgressTitle:='';
opInfo.pFrom:=pChar(sFn);
OPInfo.pTo:=pChar(dFn); if (SHFileOperation(opinfo)<>0) then
begin
ShowMessage('Îļþ²Ù×÷ʧ°Ü£¬ÏµÍ³½«Í˳ö£¡');
exit;
end; ////////////////////////////////////////////////////////////////
try
ea.Connect;
except
end;
ea.Visible[0]:=false;
eb.ConnectTo(ea.Workbooks.Open(dfn,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam,0));
ew.ConnectTo(eb.activesheet as _worksheet); rs:=Tquery.Create(application);
rs.databasename :='cnqf';
if ((frmlogin.varqxinfo.dhhb=0) and(frmlogin.varqxinfo.dhzs=0) and (frmlogin.varqxinfo.xhhb=0) and(frmlogin.varqxinfo.xhzs=0) and(frmlogin.varqxinfo.xtgly=1)and(frmlogin.varqxinfo.leader=0))or ((frmlogin.varqxinfo.xhcx=0) and (frmlogin.varqxinfo.dhcx=0))then
begin
if checkbox1.Checked and checkbox2.Checked and checkbox4.Checked then
begin
str:='select qfxx.hh,qfxx.hm,yhda.dz,qfxx.dfyf,qfxx.sjje from qfxx,yhda where (yhda.hh=qfxx.hh) and (yhda.bmbs='+''''+combo_bmbs.text+''''+')and (qfxx.dfyf>='+''''+formatDateTime('yyyy-mm',DateTimePicker1.Date)+''''+' and qfxx.dfyf<='+''''+FormatDateTime('yyyy-mm',DateTimePicker2.Date)+''''+') and (qfxx.xzdjsj>='+''''+formatDateTime('yyyy-mm-dd',DateTimePicker3.Date)+''''+' and qfxx.xzdjsj<='+''''+FormatDateTime('yyyy-mm-dd',DateTimePicker4.Date)+''''+')';
rs.Active:=false;
rs.SQL.Clear;
rs.SQL.Add(str);
rs.Active:=true;
///////////////////////////////////////////////////////////////////
rs.DisableControls;
i:=2;
while not rs.eof do
begin
stmp:=rs.fieldbyname('hh').AsString;
ew.Cells.Item[i,1]:=stmp ;
ew.Cells.Item[i,2]:=rs.fieldbyname('hm').AsString;
ew.Cells.Item[i,3]:=rs.fieldbyname('dz').AsString;
ew.Cells.Item[i,4]:=rs.fieldbyname('dfyf').AsString;
ew.Cells.Item[i,5]:=rs.fieldbyname('sjje').AsString;
i:=i+1;
rs.Next;
end; rs.EnableControls;
rs.Close;
rs.Destroy;
ea.DisplayFullScreen[0]:=true;
ea.DisplayFullScreen[0]:=false;
ea.Visible[0]:=true;
end;
if (frmlogin.varqxinfo.dhhb=1) or (frmlogin.varqxinfo.dhzs=1)then
begin
str:='select qfxx.hh,qfxx.hm,yhda.dz,qfxx.dfyf,qfxx.hdf from qfxx,yhda where (yhda.hh=qfxx.hh) and (yhda.bmbs='+''''+combo_bmbs.Text+''''+') and (qfxx.dfyf>='+''''+formatDateTime('yyyy-mm',DateTimePicker1.Date)+''''+' and qfxx.dfyf<='+''''+FormatDateTime('yyyy-mm',DateTimePicker2.Date)+''''+') and ((qfxx.xzdjsj<='+''''+formatDateTime('yyyy-mm-dd',DateTimePicker5.Date)+''''+') ) and (qfxx.xzbz='+''''+'δÏúÕÊ'+''''+')';
rs.Active:=false;
rs.SQL.Clear;
rs.SQL.Add(str);
rs.Active:=true;
///////////////////////////////////////////////////////////////////
rs.DisableControls;
i:=2;
while not rs.eof do
begin
stmp:=rs.fieldbyname('hh').AsString;
ew.Cells.Item[i,1]:=stmp ;
ew.Cells.Item[i,2]:=rs.fieldbyname('hm').AsString;
ew.Cells.Item[i,3]:=rs.fieldbyname('dz').AsString;
ew.Cells.Item[i,4]:=rs.fieldbyname('dfyf').AsString;
ew.Cells.Item[i,5]:=rs.fieldbyname('hdf').AsString;
i:=i+1;
rs.Next;
end;
这是我的一些代码,请帮忙看看问题
Dfn:=ExtractFileDir(application.ExeName)+'\reports\Êý¾Ýµ¼³öÄ£°å.xls'; opInfo.Wnd:=Handle;
opinfo.fAnyOperationsAborted:=false;
opInfo.lpszProgressTitle:='';
opInfo.pFrom:=pChar(sFn);
OPInfo.pTo:=pChar(dFn); if (SHFileOperation(opinfo)<>0) then
begin
ShowMessage('Îļþ²Ù×÷ʧ°Ü£¬ÏµÍ³½«Í˳ö£¡');
exit;
end; ////////////////////////////////////////////////////////////////
try
ea.Connect;
except
end;
ea.Visible[0]:=false;
eb.ConnectTo(ea.Workbooks.Open(dfn,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam,0));
ew.ConnectTo(eb.activesheet as _worksheet); rs:=Tquery.Create(application);
rs.databasename :='cnqf';
if ((frmlogin.varqxinfo.dhhb=0) and(frmlogin.varqxinfo.dhzs=0) and (frmlogin.varqxinfo.xhhb=0) and(frmlogin.varqxinfo.xhzs=0) and(frmlogin.varqxinfo.xtgly=1)and(frmlogin.varqxinfo.leader=0))or ((frmlogin.varqxinfo.xhcx=0) and (frmlogin.varqxinfo.dhcx=0))then
begin
if checkbox1.Checked and checkbox2.Checked and checkbox4.Checked then
begin
str:='select qfxx.hh,qfxx.hm,yhda.dz,qfxx.dfyf,qfxx.sjje from qfxx,yhda where (yhda.hh=qfxx.hh) and (yhda.bmbs='+''''+combo_bmbs.text+''''+')and (qfxx.dfyf>='+''''+formatDateTime('yyyy-mm',DateTimePicker1.Date)+''''+' and qfxx.dfyf<='+''''+FormatDateTime('yyyy-mm',DateTimePicker2.Date)+''''+') and (qfxx.xzdjsj>='+''''+formatDateTime('yyyy-mm-dd',DateTimePicker3.Date)+''''+' and qfxx.xzdjsj<='+''''+FormatDateTime('yyyy-mm-dd',DateTimePicker4.Date)+''''+')';
rs.Active:=false;
rs.SQL.Clear;
rs.SQL.Add(str);
rs.Active:=true;
///////////////////////////////////////////////////////////////////
rs.DisableControls;
i:=2;
while not rs.eof do
begin
stmp:=rs.fieldbyname('hh').AsString;
ew.Cells.Item[i,1]:=stmp ;
ew.Cells.Item[i,2]:=rs.fieldbyname('hm').AsString;
ew.Cells.Item[i,3]:=rs.fieldbyname('dz').AsString;
ew.Cells.Item[i,4]:=rs.fieldbyname('dfyf').AsString;
ew.Cells.Item[i,5]:=rs.fieldbyname('sjje').AsString;
i:=i+1;
rs.Next;
end; rs.EnableControls;
rs.Close;
rs.Destroy;
ea.DisplayFullScreen[0]:=true;
ea.DisplayFullScreen[0]:=false;
ea.Visible[0]:=true;
end;
if (frmlogin.varqxinfo.dhhb=1) or (frmlogin.varqxinfo.dhzs=1)then
begin
str:='select qfxx.hh,qfxx.hm,yhda.dz,qfxx.dfyf,qfxx.hdf from qfxx,yhda where (yhda.hh=qfxx.hh) and (yhda.bmbs='+''''+combo_bmbs.Text+''''+') and (qfxx.dfyf>='+''''+formatDateTime('yyyy-mm',DateTimePicker1.Date)+''''+' and qfxx.dfyf<='+''''+FormatDateTime('yyyy-mm',DateTimePicker2.Date)+''''+') and ((qfxx.xzdjsj<='+''''+formatDateTime('yyyy-mm-dd',DateTimePicker5.Date)+''''+') ) and (qfxx.xzbz='+''''+'δÏúÕÊ'+''''+')';
rs.Active:=false;
rs.SQL.Clear;
rs.SQL.Add(str);
rs.Active:=true;
///////////////////////////////////////////////////////////////////
rs.DisableControls;
i:=2;
while not rs.eof do
begin
stmp:=rs.fieldbyname('hh').AsString;
ew.Cells.Item[i,1]:=stmp ;
ew.Cells.Item[i,2]:=rs.fieldbyname('hm').AsString;
ew.Cells.Item[i,3]:=rs.fieldbyname('dz').AsString;
ew.Cells.Item[i,4]:=rs.fieldbyname('dfyf').AsString;
ew.Cells.Item[i,5]:=rs.fieldbyname('hdf').AsString;
i:=i+1;
rs.Next;
end;
这是我的一些代码,请看看我的问题,为什么这么慢?