具体是这样的,我要在一个数据库中根据父子两类进行导出到EXCEL,现在我已经准备好记录集,并将记录集传入一个递归函数中,我的意思是按照次序导出到EXCEL,比如
TYPENO PARENTNO NAME
1 111NAME
2 1 222NAME
3 1 333NAME
4 444NAME
5 2 555NAME根据这个记录集应该是这样排列
1--111NAME
| |
| 2--222NAME
| | |
| | 5--55NAME
| |
| |
| 3--333NAME
|
|
|
4--444NAME导出EXCEL时候应该是这样的
111NAME
222NAME
555NAME
333NAME
444NAME一定要导出成这样,显示的要错落有次序
我现在数据集不用大家来考虑
我现在把我定义的递归给大家看看,procedure TWLXGL.exportdata(AdoTemp:TClientDataSet;ExcelApp:olevariant;ShowId:string);
const ListNum:string='CDEFGHIJKLMN';
var Id:string;
procedure AddData(AdoTmp:TClientDataSet);
begin
with AdoTmp do
begin
while not eof do
begin
.....
省略过程
.....
end;
end;begin
AdoTemp.Filtered:=false;
AdoTemp.Filter:='parentno='+ShowId;
Adotemp.Filtered:=true;
if Adotemp.RecordCount<>0 then
begin
while not adotemp.Eof do
begin
id:=adotemp.fieldbyname('businesstypeno').AsString;
adotemp.Filtered:=false;
AdoTemp.Filter:='parentno='+Id;
Adotemp.Filtered:=true;
if adotemp.RecordCount=0 then
begin
adotemp.Filtered:=false;
AddData(Adotemp);
exit;
end
else exportdata(AdoTemp,ExcelApp,id);
next;
end;
end;
end;请各位大虾看看这个递归为什么不能实现我要的格式,它数据是全部导出了,但不是要要的格式
它导出的是
111NAME
444NAME
222NAME
333NAME
555NAME
这个格式不是我要的,拜托各位了,现在很急,在线等待,如果觉得100分还少,我在加
TYPENO PARENTNO NAME
1 111NAME
2 1 222NAME
3 1 333NAME
4 444NAME
5 2 555NAME根据这个记录集应该是这样排列
1--111NAME
| |
| 2--222NAME
| | |
| | 5--55NAME
| |
| |
| 3--333NAME
|
|
|
4--444NAME导出EXCEL时候应该是这样的
111NAME
222NAME
555NAME
333NAME
444NAME一定要导出成这样,显示的要错落有次序
我现在数据集不用大家来考虑
我现在把我定义的递归给大家看看,procedure TWLXGL.exportdata(AdoTemp:TClientDataSet;ExcelApp:olevariant;ShowId:string);
const ListNum:string='CDEFGHIJKLMN';
var Id:string;
procedure AddData(AdoTmp:TClientDataSet);
begin
with AdoTmp do
begin
while not eof do
begin
.....
省略过程
.....
end;
end;begin
AdoTemp.Filtered:=false;
AdoTemp.Filter:='parentno='+ShowId;
Adotemp.Filtered:=true;
if Adotemp.RecordCount<>0 then
begin
while not adotemp.Eof do
begin
id:=adotemp.fieldbyname('businesstypeno').AsString;
adotemp.Filtered:=false;
AdoTemp.Filter:='parentno='+Id;
Adotemp.Filtered:=true;
if adotemp.RecordCount=0 then
begin
adotemp.Filtered:=false;
AddData(Adotemp);
exit;
end
else exportdata(AdoTemp,ExcelApp,id);
next;
end;
end;
end;请各位大虾看看这个递归为什么不能实现我要的格式,它数据是全部导出了,但不是要要的格式
它导出的是
111NAME
444NAME
222NAME
333NAME
555NAME
这个格式不是我要的,拜托各位了,现在很急,在线等待,如果觉得100分还少,我在加
解决方案 »
- 调用dll传递record地址问题。
- 请高手看看我这程序哪里有问题啊
- 一个简单的问题,不过很急! 大家帮忙看看!!
- 如何实现这样的查询?
- 请问一下,fastreport创建交叉报表时说找不到TfrCrossView类,
- 为什么会弹出“out of system resource "对话框
- 高分求教:如何在treeview中用鼠标拖动来改变节点位置?在线给分!
- 寻mp3控件,要能读取其tag信息.
- 用ZPL II语言编写过斑马打印程序的请进!!!帮小弟看看这个问题如何解决
- 如何将*.dbf的数据表(含汉字)转为*.db的数据表?
- 本人初学delphi,要用它对数据库编程,请教各位大虾应看些什么书或资料,从何下手?
- 求助!求助!急,大家帮忙,分不够再给
你一个编号不会有好几个父编号把?
var
num,i,j:integer;
SheetNum,ShowNum:string;
MsgText:string;
MsgNum,MsgNumCount,MsgNumSpace:integer;
begin
num:=0;
with AdoTmp do
begin
while not eof do
begin
GuageNum:=GuageNum+1;
WProgress.LBShowName.Width:=WProgress.Canvas.TextWidth('正在导出业务:'+Fields[1].AsString)+20;
WProgress.LBShowName.Caption:='正在导出业务:'+Fields[1].AsString; for i:=1 to length(ListNum) do
begin
if (num=Fields[0].AsInteger) and (i in [1,2,3,4,5,6,7,9,12]) then continue;
SheetNum:=ListNum[i]+inttostr(GuageNum);
case i of
8: MsgText:='正在导出预算:';
10: MsgText:='正在导出凭证模板:';
11: MsgText:='正在导出明细界面:';
else MsgText:='';
end; if (MsgText<>'') and (AdoTemp.Fields[i].AsString<>'') then
begin
MsgNumSpace:=length(MsgText);
MsgText:=MsgText+Fields[i].AsString;
if WProgress.canvas.TextWidth(MsgText)>500 then
begin
MsgNumCount:=length(MsgText);
for MsgNum:=1 to MsgNumCount do
if WProgress.canvas.TextWidth(copy(MsgText,1,MsgNum))>500 then break;
WProgress.LBBudGet.Caption:=copy(MsgText,0,MsgNum+1)+#13+stringofchar(' ',MsgNumSpace-1)+copy(MsgText,MsgNum+2,length(MsgText));
end
else
WProgress.LBBudGet.Caption:=MsgText;
end; if i=1 then ExcelApp.activesheet.range[SheetNum+':'+SheetNum].Value:=stringofchar(' ',2*FieldByName('pilenum').AsInteger)+Fields[i].AsString
else ExcelApp.activesheet.range[SheetNum+':'+SheetNum].Value:=Fields[i].AsString+' ';
end; if num<>Fields[0].AsInteger then
begin
num:=Fields[0].AsInteger;
inc(ShowListNum);
ExcelApp.activesheet.range['b'+inttostr(GuageNum)+':b'+inttostr(GuageNum)].Value:=inttostr(ShowListNum);
end;
WProgress.Gauge.Progress:=round(GuageNum*100/GuageCount);
application.ProcessMessages;
next;
end;
end;
end;
function TForm1.AllOverTreeView(node:TTreenode):TTreenode;
begin
while node<>nil do
begin
if node.HasChildren then
begin
node:=node.getFirstChild;
allovertreeview(node);
node:=node.Parent;
end;
if node.getNextSibling<>nil then
node:=node.getNextSibling
else
exit;
end;
end;
procedure SearchTree(Nodetag:integer);
var nc:integer;
begin
//导出这条纪录
//查PARENTNO为NodeTag的纪录
while not xx.Eof do
begin
nc:=子节点
SearchTree(nc);
xx.Next;
end;
end;
那我应该在那里写ADDDATA,这个是最关键的,其他的我到不担心,你能不能结合我的程序帮我想个办法