︿︿︿︿☆☆☆QuickReport合计问题☆☆☆︿︿︿︿ 对了,如果你和程序动态动得太历害的话,那就在Page Footer和SumMary的BeforePrint中编程就行了,如Page Footer上放一个TQRLabel ,在Page Footer的BeforePrint中写QRLabel1.caption:='11222'; 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 程序如下:(请帮忙看看)procedure TfrmSalaryOutPrint.MakeQuickReport(ds: TClientDataSet);var Total,j,i:integer; QRLabeltitle,QRLabelfooter,qlPageNum:TQRLabel; QRsysdata,qs:TQRsysdata; QRLabel:array of TQRLabel; QrdbText:array of TQRDBText; pageWidth:Extended;begin// if frmSO.cdsSalaryTable.IsEmpty then exit; QRep:=TQuickRep.Create(self); QRep.parent:=self; pageWidth:=0; QRep.DataSet:=ds;//.tbl_accessqry; QRep.Bands.HasTitle:=true; {指定其具有标题} QRep.Bands.HasColumnHeader:=true; {指定其具有列头} QRep.Bands.HasDetail:=true; {指定其具有列值} QRep.Bands.HasPageFooter:=true; {指定其具有页脚} total:=ds.Fields.Count;// total:=cdsSalaryTable.Fields.Count; SetLength(QRLabel,total); SetLength(QrdbText,total); {动态创建报表标题} QRLabeltitle:=TQRLabel.Create(QRep.Bands.TitleBand); QRLabeltitle.parent:=QRep.Bands.TitleBand;// QRLabeltitle.Top:=QRep.Bands.titleBand.Top+2; QRLabeltitle.height:=23;//QRep.Bands.TitleBand.height-2; if total<7 then QRLabeltitle.left:=180 else QRLabeltitle.left:=300; QRLabeltitle.caption:='工资发放表(' + inttostr(FCurYear) + '年' + inttostr(FCurMonth) + '月)'; QRLabeltitle.Font.Name:='隶书'; QRLabeltitle.Font.size:=16; QRLabeltitle.Font.Style:=[fsbold]; QRLabeltitle.Alignment:=tacenter;// total:=cdsSalaryTable.Fields.Count; SetLength(QRLabel,total); qlPageNum:=TQRLabel.Create(QRep.Bands.PageFooterBand); qlPageNum.parent:=QRep.Bands.PageFooterband; qlPageNum.height:=23;//QRep.Bands.PageFooterband.height-2; qlPageNum.caption:='页数:'; qlPageNum.left:=330; qlPageNum.Font.Name:='宋体'; qlPageNum.Font.size:=9; qs:=TQRsysdata.Create(QRep.Bands.PageFooterband); qs.parent:=QRep.Bands.PageFooterband; qs.height:=23;//QRep.Bands.PageFooterband.height-2; qs.Data:=qrsPageNumber; qs.left:=375; qs.Font.size:=9; qs.Font.Name:='宋体'; QRLabelfooter:=TQRLabel.Create(QRep.Bands.PageFooterband); QRLabelfooter.parent:=QRep.Bands.PageFooterband; QRLabelfooter.height:=23;//QRep.Bands.PageFooterband.height-2; QRLabelfooter.caption:='打印日期:'; QRLabelfooter.left:=430; QRLabelfooter.Font.Name:='宋体'; QRLabelfooter.Font.size:=9; QRsysdata:=TQRsysdata.Create(QRep.Bands.PageFooterband); QRsysdata.parent:=QRep.Bands.PageFooterband; QRsysdata.height:=23;//QRep.Bands.PageFooterband.height-2; QRsysdata.Data:=qrsDateTime; QRsysdata.left:=510; QRsysdata.Font.size:=9; i:=0; For j:=0 to total - 1 do begin if ds.Fields[j].Visible =false then continue; application.ProcessMessages ; QRLabel[i]:=TQRLabel.Create(QRep.Bands.ColumnHeaderBand); QRLabel[i].parent:=QRep.Bands.ColumnHeaderBand; QRep.Bands.ColumnHeaderBand.Height :=23; QRep.Bands.ColumnHeaderBand.Frame.DrawTop:=true; QRep.Bands.ColumnHeaderBand.Frame.DrawLeft:=true; QRep.Bands.ColumnHeaderBand.Frame.DrawBottom:=true; QRep.Bands.ColumnHeaderBand.Frame.DrawRight:=true; QRLabel[i].height:=23;//QRep.Bands.ColumnHeaderBand.height-2;// QRLabel[i].width:=8*cdsSalaryTable.Fields[i].datasize; {一个字8个字节} QRLabel[i].AutoSize:=false; QRLabel[i].Alignment:=tacenter; if i=1 then QRLabel[i].width:=ds.Fields[j].DisplayWidth * 8 else QRLabel[i].width:=ds.Fields[j].DisplayWidth * 7; QRLabel[i].Font.Name:='宋体'; QRLabel[i].Font.size:=10;// QRLabel[i].frame.drawbottom:=true; //指定Text是否有边框// QRLabel[i].frame.drawleft:=true; if j=total-1 then QRLabel[i].Frame.DrawRight:=false else 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:=ds.Fields[j].DisplayLabel; { with query1 do begin close; sql.clear; sql.add('select * from wx_assess_setting where assess_setting_name2=:str'); params[0].AsString:=tbl_accessqry.Fields[i].DisplayLabel; showmessage(tbl_accessqry.Fields[i].DisplayLabel); prepare; open; end; QRLabel[i].Caption:=query1.fieldbyname('assess_setting_name1').asstring; } pageWidth:=pageWidth+ QRLabel[i].width; i:=i+1; end; QRep.Page.PaperSize:=Custom; QRep.Page.LeftMargin:=10; QRep.Page.Width:=400; QRep.Page.Length:=297; {动态生成列值} i:=0; For j:=0 to total - 1 do begin if ds.Fields[j].Visible =false then continue; application.ProcessMessages; QrdbText[i]:=TQrdbText.Create(QRep.Bands.DetailBand); QrdbText[i].parent:=QRep.Bands.DetailBand;// QRep.Bands.DetailBand.Frame.DrawTop:=true; QRep.Bands.DetailBand.Frame.DrawLeft:=true; QRep.Bands.DetailBand.Frame.DrawBottom:=true; QRep.Bands.DetailBand.Frame.DrawRight:=true; QRep.Bands.DetailBand.Height :=22; QrdbText[i].Autosize:=false; QrdbText[i].height:=22;//QRep.Bands.DetailBand.height; QrdbText[i].top:=0; QrdbText[i].width:= QRLabel[i].width; if i=0 then QrdbText[i].Alignment:=tacenter else if (i=1) or (i=2) then QrdbText[i].Alignment:=taleftJustify else QrdbText[i].Alignment:=taRightJustify; 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; if j=total -1 then QrdbText[i].frame.drawright:=false else QrdbText[i].frame.drawright:=true;// QrdbText[i].frame.drawtop:=true; QrdbText[i].Font.Name:='宋体'; QrdbText[i].Font.Size:=9; QrdbText[i].Dataset:=ds; QrdbText[i].DataField:=ds.Fields[j].fieldname; i:=i+1; end;end; 将 QRExpr放在页脚,Expression=sum(FieldName),ResetAfterPrint=True 用TQRExpr控件!关键是设置:1:ResetAfterPrint := true(页合计)/false(总计)2:QRExpr1.Expression := 'SUM(TotalNum)'; 在最后一页上如何设置:ResetAfterPrint ? ResetAfterPrint 对所有页是同一个设置,要显示总计还得用合计栏 如何强制结束一个事件的后续处理 求面试题答案:如果你遇到你无法解决的软件问题,你会如何办? new一个dataModel,可是query1的Connection属性并没有datamodel选项?急求大侠帮哦 关于edit的问题 那里有用DELPHI开发的单机板游戏的代码下载 我要判断2个条件中有中是否有成立的,怎么写这个判断啊????? 郁闷中,放分 註冊表代碼問題 fastreport4.6如何设置默认纸张为系统当前默认打印机的默认纸张? Delphi编译问题 能否把delphi的可执行程序反编译为源程序, 而不是汇编语言 如何使用InstallShield Express制作安装文件
procedure TfrmSalaryOutPrint.MakeQuickReport(ds: TClientDataSet);
var
Total,j,i:integer;
QRLabeltitle,QRLabelfooter,qlPageNum:TQRLabel;
QRsysdata,qs:TQRsysdata;
QRLabel:array of TQRLabel;
QrdbText:array of TQRDBText;
pageWidth:Extended;
begin
// if frmSO.cdsSalaryTable.IsEmpty then exit;
QRep:=TQuickRep.Create(self);
QRep.parent:=self;
pageWidth:=0;
QRep.DataSet:=ds;//.tbl_accessqry;
QRep.Bands.HasTitle:=true; {指定其具有标题}
QRep.Bands.HasColumnHeader:=true; {指定其具有列头}
QRep.Bands.HasDetail:=true; {指定其具有列值}
QRep.Bands.HasPageFooter:=true; {指定其具有页脚} total:=ds.Fields.Count;// total:=cdsSalaryTable.Fields.Count;
SetLength(QRLabel,total);
SetLength(QrdbText,total);
{动态创建报表标题}
QRLabeltitle:=TQRLabel.Create(QRep.Bands.TitleBand);
QRLabeltitle.parent:=QRep.Bands.TitleBand;
// QRLabeltitle.Top:=QRep.Bands.titleBand.Top+2;
QRLabeltitle.height:=23;//QRep.Bands.TitleBand.height-2;
if total<7
then
QRLabeltitle.left:=180
else
QRLabeltitle.left:=300;
QRLabeltitle.caption:='工资发放表(' + inttostr(FCurYear) + '年' + inttostr(FCurMonth) + '月)';
QRLabeltitle.Font.Name:='隶书';
QRLabeltitle.Font.size:=16;
QRLabeltitle.Font.Style:=[fsbold];
QRLabeltitle.Alignment:=tacenter;// total:=cdsSalaryTable.Fields.Count;
SetLength(QRLabel,total); qlPageNum:=TQRLabel.Create(QRep.Bands.PageFooterBand);
qlPageNum.parent:=QRep.Bands.PageFooterband;
qlPageNum.height:=23;//QRep.Bands.PageFooterband.height-2;
qlPageNum.caption:='页数:';
qlPageNum.left:=330;
qlPageNum.Font.Name:='宋体';
qlPageNum.Font.size:=9;
qs:=TQRsysdata.Create(QRep.Bands.PageFooterband);
qs.parent:=QRep.Bands.PageFooterband;
qs.height:=23;//QRep.Bands.PageFooterband.height-2;
qs.Data:=qrsPageNumber;
qs.left:=375;
qs.Font.size:=9;
qs.Font.Name:='宋体';
QRLabelfooter:=TQRLabel.Create(QRep.Bands.PageFooterband);
QRLabelfooter.parent:=QRep.Bands.PageFooterband;
QRLabelfooter.height:=23;//QRep.Bands.PageFooterband.height-2;
QRLabelfooter.caption:='打印日期:';
QRLabelfooter.left:=430;
QRLabelfooter.Font.Name:='宋体';
QRLabelfooter.Font.size:=9;
QRsysdata:=TQRsysdata.Create(QRep.Bands.PageFooterband);
QRsysdata.parent:=QRep.Bands.PageFooterband;
QRsysdata.height:=23;//QRep.Bands.PageFooterband.height-2;
QRsysdata.Data:=qrsDateTime;
QRsysdata.left:=510;
QRsysdata.Font.size:=9;
i:=0;
For j:=0 to total - 1 do
begin
if ds.Fields[j].Visible =false then continue;
application.ProcessMessages ;
QRLabel[i]:=TQRLabel.Create(QRep.Bands.ColumnHeaderBand);
QRLabel[i].parent:=QRep.Bands.ColumnHeaderBand;
QRep.Bands.ColumnHeaderBand.Height :=23;
QRep.Bands.ColumnHeaderBand.Frame.DrawTop:=true;
QRep.Bands.ColumnHeaderBand.Frame.DrawLeft:=true;
QRep.Bands.ColumnHeaderBand.Frame.DrawBottom:=true;
QRep.Bands.ColumnHeaderBand.Frame.DrawRight:=true;
QRLabel[i].height:=23;//QRep.Bands.ColumnHeaderBand.height-2;
// QRLabel[i].width:=8*cdsSalaryTable.Fields[i].datasize; {一个字8个字节}
QRLabel[i].AutoSize:=false;
QRLabel[i].Alignment:=tacenter;
if i=1 then
QRLabel[i].width:=ds.Fields[j].DisplayWidth * 8
else
QRLabel[i].width:=ds.Fields[j].DisplayWidth * 7;
QRLabel[i].Font.Name:='宋体';
QRLabel[i].Font.size:=10;
// QRLabel[i].frame.drawbottom:=true; //指定Text是否有边框
// QRLabel[i].frame.drawleft:=true;
if j=total-1 then
QRLabel[i].Frame.DrawRight:=false
else
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:=ds.Fields[j].DisplayLabel;
{ with query1 do
begin
close;
sql.clear;
sql.add('select * from wx_assess_setting where assess_setting_name2=:str');
params[0].AsString:=tbl_accessqry.Fields[i].DisplayLabel;
showmessage(tbl_accessqry.Fields[i].DisplayLabel);
prepare;
open;
end;
QRLabel[i].Caption:=query1.fieldbyname('assess_setting_name1').asstring; }
pageWidth:=pageWidth+ QRLabel[i].width;
i:=i+1;
end; QRep.Page.PaperSize:=Custom;
QRep.Page.LeftMargin:=10;
QRep.Page.Width:=400;
QRep.Page.Length:=297; {动态生成列值}
i:=0;
For j:=0 to total - 1 do
begin
if ds.Fields[j].Visible =false then continue;
application.ProcessMessages;
QrdbText[i]:=TQrdbText.Create(QRep.Bands.DetailBand);
QrdbText[i].parent:=QRep.Bands.DetailBand;
// QRep.Bands.DetailBand.Frame.DrawTop:=true;
QRep.Bands.DetailBand.Frame.DrawLeft:=true;
QRep.Bands.DetailBand.Frame.DrawBottom:=true;
QRep.Bands.DetailBand.Frame.DrawRight:=true;
QRep.Bands.DetailBand.Height :=22;
QrdbText[i].Autosize:=false;
QrdbText[i].height:=22;//QRep.Bands.DetailBand.height;
QrdbText[i].top:=0;
QrdbText[i].width:= QRLabel[i].width;
if i=0 then
QrdbText[i].Alignment:=tacenter
else if (i=1) or (i=2) then
QrdbText[i].Alignment:=taleftJustify
else
QrdbText[i].Alignment:=taRightJustify; 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;
if j=total -1 then
QrdbText[i].frame.drawright:=false
else
QrdbText[i].frame.drawright:=true;
// QrdbText[i].frame.drawtop:=true;
QrdbText[i].Font.Name:='宋体';
QrdbText[i].Font.Size:=9;
QrdbText[i].Dataset:=ds;
QrdbText[i].DataField:=ds.Fields[j].fieldname;
i:=i+1;
end;end;
关键是设置:
1:ResetAfterPrint := true(页合计)/false(总计)
2:QRExpr1.Expression := 'SUM(TotalNum)';