Delphi程序执行时实时生成报表(4)

2008-04-09 04:30:07来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折


end;
1: if ColWd.Text<>'''''''' then ObWidth:=StrToInt(ColWd.Text)
else ObWidth:=100;//相同宽度:ObWidth=输入宽度值
2: begin //限制最大宽度:首先按自动宽度计算再判断宽度是否超最大值,
//如果超过则ObWidth=最大宽度输入值
if ColWd.Text<>'''''''' then Cd:=StrToInt(ColWd.Text)
else Cd:=200;
ObWidth:=L*6;
if ObWidth>Cd then ObWidth:=Cd;
ObWidth:=ObWidth 2;
if (Query.Fields[I].DataType=ftDateTime) or
(Query.Fields[I].DataType=ftFloat) or
(Query.Fields[I].DataType=ftCurrency) then ObWidth:=65;
end;
end;

if CHBlf ObWidth>=HB.Width then begin //建立控件>纸宽?
DlgMes:=''''纸张宽度不够,请更改纸张尺寸。'''';
MessageBox(Handle,DlgMes,Cap_Inf,Ico_Inf);
break;
end
else begin
CHBShape[I]:=TQRShape.Create(HB);//建立列标头带区线条控件
CHBShape[I].Parent:=HB;
CHBShape[I].Top:=CHBtp;
CHBShape[I].Left:=CHBlf;
CHBShape[I].Width:=ObWidth 1;
CHBShape[I].Height:=17;

CHBNAME[I]:=TQRLabel.Create(HB); //建立列标题控件
CHBNAME[I].Parent:=HB;
CHBNAME[I].Top:=CHBtp 2;
CHBNAME[I].Left:=CHBlf 1;
CHBNAME[I].AutoSize:=False;
CHBNAME[I].Width:=ObWidth-1;
CHBNAME[I].Alignment:=taCenter;
CHBNAME[I].Caption:=Query.Fields[I].DisplayName;//取字段作为列名
CHBNAME[I].BringToFront;

DBShape[I]:=TQRShape.Create(DB); //建立细节带区线条控件
DBShape[I].Parent:=DB;
DBShape[I].Top:=-1;
DBShape[I].Left:=CHBlf;
DBShape[I].Width:=ObWidth 1;
DBShape[I].Height:=17;

DBNAME[I]:=TQRDBText.Create(DB); //建立细节带区控件
DBNAME[I].Parent:=DB;
DBNAME[I].ParentReport:=QuickRep;
DBNAME[I].Top:=2;
DBNAME[I].Left:=CHBlf 2;
DBNAME[I].AutoSize:=False;
DBNAME[I].Width:=ObWidth-3;
DBNAME[I].Height:=13;
DBNAME[I].Alignment:=Dj;
DBNAME[I].DataSet:=Query;
DBNAME[I].DataField:=Query.Fields[I].FieldName;
DBNAME[I].BringToFront;

if Tj1.Checked then begin //是否建立页脚带区?
FBShape[I]:=TQRShape.Create(FB); //建立页脚带区线条控件
FBShape[I].Parent:=FB;
FBShape[I].Top:=0;
FBShape[I].Left:=CHBlf;
FBShape[I].Width:=ObWidth 1;
FBShape[I].Height:=17;

if (Query.Fields[I].DataType=ftFloat) or
(Query.Fields[I].DataType=ftCurrency) or (I<2) then
begin //如果字段类型为数值类型则建立
FBNAME[I]:=TQRExpr.Create(FB); //建立页脚带区控件
FBNAME[I].Parent:=FB;
FBNAME[I].ParentReport:=QuickRep;
FBNAME[I].Top:=3;
FBNAME[I].Left:=CHBlf 2;
FBNAME[I].AutoSize:=False;
FBNAME[I].Width:=ObWidth-3;
FBNAME[I].Height:=13;
FBNAME[I].Alignment:=taCenter;
FBNAME[I].Expression:=''''SUM(QUERY.'''' Query.Fields[I].FieldName '''')'''';
FBNAME[I].BringToFront;
end;
end;

if Tj2.Checked then begin //是否建立总和带区?
SumShape[I]:=TQRShape.Create(SB); //建立总和带区线条控件
SumShape[I].Parent:=SB;
SumShape[I].Top:=0;
SumShape[I].Left:=CHBlf;
SumShape[I].Width:=ObWidth 1;
SumShape[I].Height:=17;

if (Query.Fields[I].DataType=ftFloat) or
(Query.Fields[I].DataType=ftCurrency) or (I<2) then
begin //如果字段类型为数值类型则建立
SumNAME[I]:=TQRExpr.Create(SB); //建立总和带区控件
SumNAME[I].Parent:=SB;
SumNAME[I].ParentReport:=QuickRep;
SumNAME[I].Top:=3;
SumNAME[I].Left:=CHBlf 2;
SumNAME[I].AutoSize:=False;
SumNAME[I].Width:=ObWidth-3;
SumNAME[I].Height:=13;
SumNAME[I].Alignment:=taCenter;
SumNAME[I].Expression:=''''SUM(QUERY.'''' Query.Fields[I].FieldName '''')'''';
SumNAME[I].BringToFront;
end;
end;
CHBlf:=CHBlf ObWidth;//当前字段处理完成,往右一个字段宽度
end;
end;
end;
CrtRep.Enabled:=False;//禁上生成按钮
BtnPrint.Enabled:=not CrtRep.Enabled;允许打印铵钮
BtnPrview.Enabled:=BtnPrint.Enabled;允许预览按钮
if Tj1.Checked then begin //如果建立了页脚带区,则将页脚带区中前两列更改
FBNAME[0].Expression:=''''''''''''页合计'''''''''''';
FBNAME[1].Expression:=''''COUNT ''''''''行'''''''''''';
end;
if Tj1.Checked then begin //如果建立了总和带区,则将总和带区中前两列更改
SumNAME[0].Expression:=''''''''''''总计'''''''''''';
SumNAME[1].Expression:=''''COUNT ''''''''行'''''''''''';

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:Delphi的压缩流与解压流

下一篇:在stringgrid控件中使文字内容在cell中做到上下居中