Qreport 填满最后一页的空白
来源:互联网 发布:js 转unicode 编辑:程序博客网 时间:2024/04/29 15:07
通常情况下,可以考虑用qrloopband来。qrloopband设计时一般在detailband之后,可以通过qrloopband.enable来控制qrloopband的显示与否,在最后一页计算需要多少行空白页,然后将qrloopband.enable:= true,并且设计qrloopband.printcount:=行数。
我是在动态生成报表的情况下,quickrep 等所有组件都是动态生成的。如果使用qrloopband,始终无法控制qrloopband的位置在detailband后,并且跟着detailband打印。所以最后使用detailband.childband(将detailband.haschild:=true)。也是通过控制enable来控制显示。先quickrep.prepare,并在最后一页时计算行数n,然后quickrep.preview,在最后一行时根据刚才的计算动态生成n行qrshape(表示表格线)。
程序如下:(有些部门非必须,是测试用的,待注释)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, QuickRpt, QRCtrls, DB, ADODB, ExtCtrls;
type
TForm1 = class(TForm)
QuickRep1: TQuickRep;
DetailBand1: TQRBand;
ADOTable1: TADOTable;
QRDBText1: TQRDBText;
ChildBand1: TQRChildBand;
QRLabel1: TQRLabel;
SummaryBand1: TQRBand;
procedure DetailBand1BeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
procedure DetailBand1AfterPrint(Sender: TQRCustomBand;
BandPrinted: Boolean);
procedure ChildBand1AfterPrint(Sender: TQRCustomBand;
BandPrinted: Boolean);
procedure ChildBand1BeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
procedure FormCreate(Sender: TObject);
procedure QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
private
{ Private declarations }
lt:TStrings;
index:Integer;
j:Integer;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.DetailBand1BeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
begin
lt.Add('detailb'+':'+inttostr(QuickRep1.CurrentY));
end;
procedure TForm1.DetailBand1AfterPrint(Sender: TQRCustomBand;
BandPrinted: Boolean);
var
I: Integer;
sh :TQRshape;
begin
lt.Add('detaila:'+inttostr(QuickRep1.CurrentY));
// if QuickRep1.RecordCount=QuickRep1.RecordNumber then
// begin
// ChildBand1.Enabled := true;
//
// end
// else
// ChildBand1.Enabled := false;
ChildBand1.Enabled := false;
if index=1 then
begin
if QuickRep1.RecordCount=QuickRep1.RecordNumber then
begin
if QuickRep1.CurrentY+QuickRep1.Bands.SummaryBand.Size.Height+40<
QuickRep1.Page.Length-QuickRep1.Page.BottomMargin then
begin
j := trunc((QuickRep1.Page.Length-QuickRep1.Page.BottomMargin-
QuickRep1.CurrentY-QuickRep1.Bands.SummaryBand.Size.Height) / (106) );
QuickRep1.Bands.DetailBand.ChildBand.Enabled := true;
end;
end;
end
else begin
if QuickRep1.RecordCount=QuickRep1.RecordNumber then
begin
QuickRep1.Bands.DetailBand.ChildBand.Enabled := true;
end
else
QuickRep1.Bands.DetailBand.ChildBand.Enabled := false;
end;
end;
procedure TForm1.ChildBand1AfterPrint(Sender: TQRCustomBand;
BandPrinted: Boolean);
begin
lt.Add('ca');
end;
procedure TForm1.ChildBand1BeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
begin
lt.Add('cb');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
lt := TStringList.Create;
index := 1;
QuickRep1.Prepare;
index := 2;
QuickRep1.PreviewModal;
lt.SaveToFile('I:/tmp/theight.txt');
lt.Free;
end;
procedure TForm1.QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
var
sh:TQRShape;
i:Integer;
begin
if index=2 then
begin
for I := 0 to j - 1 do // Iterate
begin
sh := TQRShape.Create(nil);
sh.Parent := QuickRep1.Bands.DetailBand.ChildBand;
sh.Top := 40*i;
sh.Left := 10;
sh.Width := 300;
sh.Height := 41;
end; // for
QuickRep1.Bands.DetailBand.ChildBand.Height := 40 * j+2;
end;
end;
end.
- Qreport 填满最后一页的空白
- eXtremeComponents 的最后一页
- dataGridView的最后空白一行
- 如何解决latex中图表在明明页面还有空白部分的情况下自动调整到最后一页的问题
- asp.net显示第一页、上一页、下一页和最后一页的分页显示数据表的数据
- easyui的datagrid的右侧区域空白及列数横向不能填满
- 去掉DataGridView最后一行的空白行,删除空白行
- 2011 最后一页
- 删除论文中word的最后一页空白页
- AndroidApplication最后一页的时候,再按一次退出
- Latex双栏布局最后一页底部对齐的处理
- 返回上一页,返回到最后一页的时候回调
- Datagrid里面如何捕获前一页下一页最后页最前页的事件?
- ViewFlipper 控制第一页和最后一页
- 求实现datagrid 第一页,最后一页
- 分页实现-----首页、上一页、下一页、最后一页
- WinForm 中DataGridView不显示最后空白的行
- DataGrid 分页—最后一页
- JAVA Calendar详解
- 钻研还是交流
- MYSQL ODBC 乱码的解决方法
- CSDN的编辑器是开源的
- 一个IBM笔试题砝码问题!有很多解
- Qreport 填满最后一页的空白
- DW related.
- 網頁配色工具收集
- Session详解
- 提高查询速度的方法
- 提高数据库查询速度的方法
- About Windows CE SerialBoot
- DataGrid的几个小技巧
- 一个JAVA调用存储过程的小例子