用QuickReport~~根据选择动态生成那些TQRDBText之类的等等东东~~~
解决方案 »
- IdHTTP Get网页出错 http 1.1 500 Internal Server Error.求解?
- 如何关联动态产生的控件的事件?
- aodquery删除多条纪录出错!高手给我看看!
- 表A有一个字段ID,是自增的,在插入记录后如何获得插入记录的ID号。
- 推荐几本Delphi的书,希望深入学习Delphi。谢谢!
- 连接oracle的问题
- 关于ado的查询进度问题!!!!(必给分)
- dll与MDI
- "Stream write error" 是什么错误?
- 大家帮一下我这只菜鸟????????
- 问问大侠,能安装数据库应用程序和它所基于的数据库的这样的安装程序怎么作?
- 十万火急,哪位大師能救救命!!!送99分啦<zzllabc / cobi/ 各位大俠請進來>
也有很多控件。
有的用类似excel的方法。(不是调用excel)
有的动态生成。且用户可以修改。
我的email:
[email protected]
我们可以研究一下的。
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,QuickRpt, Qrctrls, Db, ADODB;type
TForm1 = class(TForm)
Button1: TButton;
Query1: TADOQuery;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
QRep:TQuickRep;
QRLabel:array of TQRLabel;
QrdbText:array of TQrdbText;
procedure MakeRep;
procedure RepFree;
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementationuses Unit2, Unit3;{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
begin
MakeRep;
QRep.Preview;
RepFree;
//form2.QuickRep1.Preview;
end;procedure TForm1.MakeRep;
var Total,i:integer;
begin
QRep:=TQuickRep.Create(self);
QRep.parent:=self;
QRep.DataSet:=Query1;
QRep.Bands.HasColumnHeader:=true; //指定其具有列头
QRep.Bands.HasDetail:=true; //指定其具有列值
// QRep.AfterPreview:=FreeRept; //FreeRept是一个过程,在
//过程中自动释放掉报表
total:=Query1.Fields.Count;
SetLength(QRLabel,total);
SetLength(QrdbText,total);
//动态生成列头
For i:=0 to total - 1 do
begin
QRLabel[i]:=TQRLabel.Create(QRep.Bands.ColumnHeaderBand);
QRLabel[i].parent:=QRep.Bands.ColumnHeaderBand;
QRLabel[i].height:=QRep.Bands.ColumnHeaderBand.height-2;
QRLabel[i].width:=Query1.Fields[i].DisplayWidth;
QRLabel[i].frame.drawbottom:=true; //指定Text是否有边框
QRLabel[i].frame.drawleft:=true;
QRLabel[i].frame.drawright:=true;
QRLabel[i].frame.drawtop:=true;
QRLabel[i].Top:=1;
if i=0 then QRLabel[i].Left:=0
else QRLabel[i].left:=QRlabel[i-1].left+QRLabel[i-1].width;
QRLabel[i].Caption:=Query1.Fields[i].DisplayLabel;
end;
//动态生成列值
For i:=0 to total - 1 do
begin
QrdbText[i]:=TQrdbText.Create(QRep.Bands.DetailBand);
QrdbText[i].parent:=QRep.Bands.DetailBand;
QrdbText[i].Autosize:=false;
QrdbText[i].height:=QRep.Bands.DetailBand.height;
QrdbText[i].top:=-2;
QrdbText[i].width:= QRLabel[i].width;
if i=0 then QrdbText[i].Left:=0
else QrdbText[i].left:=QrdbText[i-1].left+QrdbText[i-1].width;
QrdbText[i].frame.drawbottom:=true; //指定Text是否有边框
QrdbText[i].frame.drawleft:=true;
QrdbText[i].frame.drawright:=true;
QrdbText[i].frame.drawtop:=true;
QrdbText[i].Dataset:=Query1;
QrdbText[i].DataField:=Query1.Fields[i].fieldname;
end;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
MakeRep;
QRep.Print;
RepFree;
end;procedure TForm1.RepFree;
var i:integer;
begin
for i:=0 to ComponentCount-1 do
begin
if (Components[i].ClassType=TQRLabel) or (Components[i].ClassType=TQrdbText) then
TQRLabel(Components[i]).Free;
end;
end;end.