W
wst
Unregistered / Unconfirmed
GUEST, unregistred user!
各位渴望得到动态生成报表的兄弟,大家一起来探讨!
我有一动态生成报表程序,程序如下,但不知为什么,实现了标题和字报表头的打印,报表内容不能显示出来,我将我的程序拿来,让大家研究一下:
procedure TForm1.Button1Click(Sender: TObject);
begin
prepareprint;
with form2do
begin
quickrep1.preview;
table1.close;
table2.close;
end;
end;
procedure tForm1.prepareprint;
var leftvalue:integer;
alabel:tqrlabel;
atext:tqrdbtext;
begin
leftvalue:=100;
with form2do
begin
alabel:=tqrlabel.create(form2);
alabel.parent:=titleband1;
with alabeldo
begin
Width:=300;
Height:=TitleBand1.Height;
Alignment:=taCenter;
Caption := Edit1.Text;
end;
Table1.Open;
Table2.Open;
table1.First;
Table2.First;
while not Table2.EOFdo
begin
aLabel := TQRLabel.Create(Form2);
//设置显示字段标题
aLabel.Parent := HeaderBand1;
with aLabeldo
begin
AutoSize:=False;
AutoStretch:=True;
Left :=LeftValue;
Top := 0;
Width:=80;
Height:=HeaderBand1.Height;
Alignment:=taCenter;
Caption := ' '+table2.FieldbyName(
'DisplayName').AsString+' ';
//报表表头来自于table2
end;
aText := TQRDBText.Create(Form2);
//设置显示字段内容
aText.Parent := DetailBand1;
with aTextdo
begin
AutoSize:=False;
AutoStretch:=True;
Height:=DetailBand1.Height;
DataSet:=Table1;
//显示的内容为table1
DataField:=Table2.FieldbyName(
'FieldsName').AsString;
//对应的字段名来自于table2
Alignment:=taCenter;
end;
LeftValue:=LeftValue+80;
Table2.Next;
end;
end;
end;
end.
我有一动态生成报表程序,程序如下,但不知为什么,实现了标题和字报表头的打印,报表内容不能显示出来,我将我的程序拿来,让大家研究一下:
procedure TForm1.Button1Click(Sender: TObject);
begin
prepareprint;
with form2do
begin
quickrep1.preview;
table1.close;
table2.close;
end;
end;
procedure tForm1.prepareprint;
var leftvalue:integer;
alabel:tqrlabel;
atext:tqrdbtext;
begin
leftvalue:=100;
with form2do
begin
alabel:=tqrlabel.create(form2);
alabel.parent:=titleband1;
with alabeldo
begin
Width:=300;
Height:=TitleBand1.Height;
Alignment:=taCenter;
Caption := Edit1.Text;
end;
Table1.Open;
Table2.Open;
table1.First;
Table2.First;
while not Table2.EOFdo
begin
aLabel := TQRLabel.Create(Form2);
//设置显示字段标题
aLabel.Parent := HeaderBand1;
with aLabeldo
begin
AutoSize:=False;
AutoStretch:=True;
Left :=LeftValue;
Top := 0;
Width:=80;
Height:=HeaderBand1.Height;
Alignment:=taCenter;
Caption := ' '+table2.FieldbyName(
'DisplayName').AsString+' ';
//报表表头来自于table2
end;
aText := TQRDBText.Create(Form2);
//设置显示字段内容
aText.Parent := DetailBand1;
with aTextdo
begin
AutoSize:=False;
AutoStretch:=True;
Height:=DetailBand1.Height;
DataSet:=Table1;
//显示的内容为table1
DataField:=Table2.FieldbyName(
'FieldsName').AsString;
//对应的字段名来自于table2
Alignment:=taCenter;
end;
LeftValue:=LeftValue+80;
Table2.Next;
end;
end;
end;
end.