动态报表设计 在涉及到财务会计模块时,对报表的要求很多并且要求报表的动态设计,而动态报表的设计一向是一个不是很容易的问题,大家来谈一下动态报表的设计,给彼此提供一些思路,谢谢踊跃发言 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 报表是很多人都头疼的问题,最有效的方法就是自己写打印过程。用TPrinter 自己定义过程:procedure TForm5.MakeRep;var i,j:integer;begin QRep:=TQuickRep.Create(self); QRep.parent:=self; QRep.DataSet:=Query1; QRep.Bands.HasPageHeader:=true; QRep.Bands.HasColumnHeader:=true; //指定其具有列头 QRep.Bands.HasDetail:=true; QRep.Bands.DetailBand.Height:=30; //指定其具有列值. //QRep.AfterPreview:=FreeRept; //FreeRept是一个过程,在 //过程中自动释放掉报表 total:=Query1.Fields.Count; //SetLength(QRLabel1,total); SetLength(QRLabel,total); SetLength(QrdbText,total); QRep.bands.ColumnHeaderBand.height:=100; //动态生成列头 QRLabelbt:=TQRLabel.Create(QRep.Bands.ColumnHeaderBand); QRlabelbt.Parent:=QRep.Bands.ColumnHeaderBand; QRlabelbt.Top:=26; QRlabelbt.Caption:='在职人员花名册'; QRlabel1.Left:=(QRep.Bands.ColumnHeaderBand.Width div 2)-(QRlabelbt.Width div 2); QRlabelbt.Height:=30; QRlabelbt.Font.Size:=18; QRlabelbt.Font.Style:=[fsbold]; width:=0; QRShape1.Left:=0; j:=1; For i:=0 to total - 1 do begin QRLabel[i]:=TQRLabel.Create(QRep.Bands.ColumnHeaderBand); QRLabel[i].parent:=QRep.Bands.ColumnHeaderBand; QRLabel[i].width:=Query1.Fields[i].DisplayWidth; QRLabel[i].Caption:=Query1.Fields[i].DisplayLabel; QRLabel[i].frame.drawbottom:=true; //指定Text是否有边框 QRLabel[i].frame.drawleft:=true; QRLabel[i].frame.drawright:=true; QRLabel[i].frame.drawtop:=true; QRLabel[i].height:=40; QRLabel[i].Top:=59;//QRep.Bands.ColumnHeaderBand.height; if i=0 then QRLabel[i].Left:=0 else QRLabel[i].left:=QRlabel[i-1].left+QRLabel[i-1].width; 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].Alignment:=taCenter; QrdbText[i].height:=QRep.Bands.DetailBand.height; QrdbText[i].top:=0; 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; //让Qrlabel的父为QRep.Bands.DetailBand, 显示时显示Qrlabel.caption+Qrdbtext.datafield; end;end; 最简单的方法:用Excel做好模板,将结果输出到Excel文件中,这样就把打印这一块解决了 dbgridEh 如何在单击编辑单元格时 自动赋值给某一单元格 散分:分享一种窗体融合的方法 为什么用程序 备份 MYSQL 不行 怎么把ComboBox置成不可编辑状态? 谁给我一个有关socket传输消息的例子!! 关于MSComm控件的使用问题, 两个DATA数据包比较的问题 PageControl1改变颜色的最简单方法是? 怎样将DELPHI的编辑器全屏? 又一个没有错误提示的问题? 关于CTRL+C,与CTRL+V ?????? dbgrid和excel
procedure TForm5.MakeRep;
var i,j:integer;
begin
QRep:=TQuickRep.Create(self);
QRep.parent:=self;
QRep.DataSet:=Query1;
QRep.Bands.HasPageHeader:=true;
QRep.Bands.HasColumnHeader:=true; //指定其具有列头
QRep.Bands.HasDetail:=true;
QRep.Bands.DetailBand.Height:=30; //指定其具有列值.
//QRep.AfterPreview:=FreeRept; //FreeRept是一个过程,在
//过程中自动释放掉报表
total:=Query1.Fields.Count;
//SetLength(QRLabel1,total);
SetLength(QRLabel,total);
SetLength(QrdbText,total);
QRep.bands.ColumnHeaderBand.height:=100;
//动态生成列头
QRLabelbt:=TQRLabel.Create(QRep.Bands.ColumnHeaderBand);
QRlabelbt.Parent:=QRep.Bands.ColumnHeaderBand;
QRlabelbt.Top:=26;
QRlabelbt.Caption:='在职人员花名册';
QRlabel1.Left:=(QRep.Bands.ColumnHeaderBand.Width div 2)-(QRlabelbt.Width div 2);
QRlabelbt.Height:=30;
QRlabelbt.Font.Size:=18;
QRlabelbt.Font.Style:=[fsbold];
width:=0;
QRShape1.Left:=0;
j:=1;
For i:=0 to total - 1 do
begin
QRLabel[i]:=TQRLabel.Create(QRep.Bands.ColumnHeaderBand);
QRLabel[i].parent:=QRep.Bands.ColumnHeaderBand;
QRLabel[i].width:=Query1.Fields[i].DisplayWidth;
QRLabel[i].Caption:=Query1.Fields[i].DisplayLabel;
QRLabel[i].frame.drawbottom:=true; //指定Text是否有边框
QRLabel[i].frame.drawleft:=true;
QRLabel[i].frame.drawright:=true;
QRLabel[i].frame.drawtop:=true;
QRLabel[i].height:=40;
QRLabel[i].Top:=59;//QRep.Bands.ColumnHeaderBand.height;
if i=0 then
QRLabel[i].Left:=0
else QRLabel[i].left:=QRlabel[i-1].left+QRLabel[i-1].width;
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].Alignment:=taCenter;
QrdbText[i].height:=QRep.Bands.DetailBand.height;
QrdbText[i].top:=0;
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;
//让Qrlabel的父为QRep.Bands.DetailBand, 显示时显示Qrlabel.caption+Qrdbtext.datafield; end;
end;