首先判断已有的数据,然后循环输出没有数据的表格。
代码如下:
for i:=first to numdo
begin
memo:=tfrmemoview.Create;
memo.FrameTyp:=15;
if i=first then
left:=left else
left:=left+query.Fields[i-1].DisplayWidth*6;
memo.SetBounds(left,195,query.Fields.displaywidth*6,20);
memo.Memo.Add(query.Fields.DisplayName);
memo.Prop['alignment']:=frtacenter;
frreport.Pages[0].Objects.add(memo);
end;
memo:=tfrmemoview.Create;
memo.FrameTyp:=15;
memo.SetBounds(606,195,84,20);
memo.Memo.Add('备注');
memo.Prop['alignment']:=frtacenter;
frreport.Pages[0].Objects.add(memo);
left:=60;
band:=tfrbandview.Create;
band.SetBounds(0,235,0,20);
band.BandType:=btmasterdata;
frreport.Pages[0].Objects.add(band);
for i:=first to numdo
begin
memo:=tfrmemoview.Create;
memo.FrameTyp:=15;
if i=first then
left:=left else
left:=left+query.Fields[i-1].DisplayWidth*6;
memo.SetBounds(left,235,query.Fields.displaywidth*6,20);
memo.Memo.Add('[query."'+query.Fields.FieldName+'"]');
frreport.Pages[0].Objects.add(memo);
end;
memo:=tfrmemoview.Create;
memo.FrameTyp:=15;
memo.SetBounds(606,235,84,20);
memo.Memo.Add('');
frreport.Pages[0].Objects.add(memo);
band:=tfrbandview.Create;
band.SetBounds(0,275,0,600);
band.BandType:=btMasterFooter;
frreport.Pages[0].Objects.add(band);
for j:=0 to 10-query.RecordCount-1do
begin
left:=60;
for i:=first to numdo
begin
memo:=tfrmemoview.Create;
memo.FrameTyp:=15;
if i=first then
left:=left else
left:=left+query.Fields[i-1].DisplayWidth*6;
memo.SetBounds(left,275+j*20,query.Fields.displaywidth*6,20);
memo.Memo.Add('');
frreport.Pages[0].Objects.add(memo);
end;
memo:=tfrmemoview.Create;
memo.FrameTyp:=15;
memo.SetBounds(606,275+j*20,84,20);
memo.Memo.Add('');
frreport.Pages[0].Objects.add(memo);
end;
各长度可以自由定义。