我是这样实现的:①计算Detail的所占纸面的高度,然后计算记录的个数,在打印时操作detail band的栏高:实际栏高= Detail应占的高度 / 记录个数②或在最后打印一个空白的Band,这个空白Band的高度为:Detail应占的高度-每个Detail Band 的高度*打印的记录个数
Detail的ForceNewPage设为True 即可
举例(只是举例,不考虑其他因素)procedure TfrmR6.QRBlankBeforePrint(Sender: TQRCustomBand;//这是空白BANK var PrintBand: Boolean); begin QRBlank.Height := 198-28*i; //默认所有记录打印高度198,单条记录打印28,剩下的就是空白行的高度。 end;procedure TfrmR6.QRGroup1BeforePrint(Sender: TQRCustomBand;//打印前复位计数器 var PrintBand: Boolean); begin i:=0;//计数器i 复位 end;procedure TfrmR6.DetailBand1BeforePrint(Sender: TQRCustomBand; var PrintBand: Boolean); begin i:=i+1;//每打印一条,计数器加一 end;
//不使用报表数据库控件,只使用TQRLabel.且QuickRep1、QRSubDetail1的DataSet属性设为空, procedure TForm2.QRSubDetail1NeedData(Sender: TObject; var MoreData: Boolean); begin MoreData:=True; if Form1.Table1.Eof then begin if ((i-1) MOD iLineHeight =0 ) then //如果当前打印的行数为每页行数的整数倍,且表已结尾,而结束打印,否则继续打印 MoreData:=False; end; if Form1.Table1.Eof then begin QRLabel1.Caption:=''; QRLabel3.Caption:=''; if (i MOD iLineHeight = 0 ) then begin QRLabel1.Caption:=IntToStr(Sum1); QRLabel3.Caption:=IntToStr(Sum2); end; QRLabel5.Caption:=''; QRLabel11.Caption:=''; QRLabel13.Caption:=''; end else begin QRLabel1.Caption:=Form1.Table1.fieldbyname('Company').AsString; QRLabel3.Caption:=Form1.Table1.fieldbyname('CustNo').AsString; QRLabel5.Caption:=Form1.Table1.fieldbyname('Addr1').AsString; QRLabel11.Caption:=Form1.Table1.fieldbyname('Phone').AsString; QRLabel13.Caption:=Form1.Table1.fieldbyname('Fax').AsString; if Form1.Table1.fieldbyname('TaxRate').AsInteger=0 then Inc(Sum1) else Inc(Sum2); Form1.Table1.Next; end; QRLabel2.Caption:=IntToStr(i-1); Inc(i); end;procedure TForm2.QuickRep1BeforePrint(Sender: TCustomQuickRep; var PrintReport: Boolean); begin Form1.Table1.First; iLineHeight:=( Trunc( QuickRep1.Height - ( ( QuickRep1.Page.TopMargin /QuickRep1.Page.Length ) * QuickRep1.Height //页头高度 + ( QuickRep1.Page.BottomMargin /QuickRep1.Page.Length ) * QuickRep1.Height //页尾高度 ) - QRBand1.Height //标题1高度 - QRChildBand1.Height //标题2高度 ) DIV QRSubDetail1.Height //每行高度 ); //每页行数=(报表的高度-上边界的高度-下边界的高度-页头1高度-页头2高度) DIV 每行高度 i:=1; Sum1:=0; Sum2:=0; end;
太麻烦了吧! 哪里有QRBlank和QRGroup倥件?我怎么没找到
这是dfm代码,仅供参考!------------- object frmR6: TfrmR6 Left = 394 Top = 273 BorderIcons = [biSystemMenu] BorderStyle = bsSingle Caption = '锣眀咎靡' ClientHeight = 184 ClientWidth = 364 Color = clBtnFace Font.Charset = ANSI_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'Arial' Font.Style = [] OldCreateOrder = False Position = poMainFormCenter Scaled = False OnCreate = FormCreate PixelsPerInch = 96 TextHeight = 14 object Label3: TLabel Left = 84 Top = 46 Width = 50 Height = 13 AutoSize = False Caption = '秨﹍ら戳' end object Label4: TLabel Left = 84 Top = 74 Width = 53 Height = 13 AutoSize = False Caption = '挡ら戳' end object LbeginNo: TLabel Left = 84 Top = 102 Width = 51 Height = 13 AutoSize = False Caption = '秨﹍肚布' end object LendNo: TLabel Left = 84 Top = 130 Width = 54 Height = 13 AutoSize = False Caption = '挡肚布' end object RG1: TRadioGroup Left = 3 Top = 3 Width = 66 Height = 140 ItemIndex = 0 Items.Strings = ( 'ず眀' '眀') TabOrder = 0 end object StaticText1: TStaticText Left = 84 Top = 18 Width = 52 Height = 18 Caption = 'そ腹' TabOrder = 1 end
我是这样实现的:①计算Detail的所占纸面的高度,然后计算记录的个数,在打印时操作detail band的栏高:实际栏高= Detail应占的高度 / 记录个数②或在最后打印一个空白的Band,这个空白Band的高度为:Detail应占的高度-每个Detail Band 的高度*打印的记录个数
var PrintBand: Boolean);
begin
QRBlank.Height := 198-28*i; //默认所有记录打印高度198,单条记录打印28,剩下的就是空白行的高度。
end;procedure TfrmR6.QRGroup1BeforePrint(Sender: TQRCustomBand;//打印前复位计数器
var PrintBand: Boolean);
begin
i:=0;//计数器i 复位
end;procedure TfrmR6.DetailBand1BeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
begin
i:=i+1;//每打印一条,计数器加一
end;
procedure TForm2.QRSubDetail1NeedData(Sender: TObject;
var MoreData: Boolean);
begin
MoreData:=True;
if Form1.Table1.Eof then
begin
if ((i-1) MOD iLineHeight =0 ) then
//如果当前打印的行数为每页行数的整数倍,且表已结尾,而结束打印,否则继续打印
MoreData:=False;
end;
if Form1.Table1.Eof then
begin
QRLabel1.Caption:='';
QRLabel3.Caption:='';
if (i MOD iLineHeight = 0 ) then
begin
QRLabel1.Caption:=IntToStr(Sum1);
QRLabel3.Caption:=IntToStr(Sum2);
end;
QRLabel5.Caption:='';
QRLabel11.Caption:='';
QRLabel13.Caption:='';
end
else
begin
QRLabel1.Caption:=Form1.Table1.fieldbyname('Company').AsString;
QRLabel3.Caption:=Form1.Table1.fieldbyname('CustNo').AsString;
QRLabel5.Caption:=Form1.Table1.fieldbyname('Addr1').AsString;
QRLabel11.Caption:=Form1.Table1.fieldbyname('Phone').AsString;
QRLabel13.Caption:=Form1.Table1.fieldbyname('Fax').AsString;
if Form1.Table1.fieldbyname('TaxRate').AsInteger=0 then
Inc(Sum1)
else
Inc(Sum2);
Form1.Table1.Next;
end;
QRLabel2.Caption:=IntToStr(i-1);
Inc(i);
end;procedure TForm2.QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
begin
Form1.Table1.First;
iLineHeight:=( Trunc( QuickRep1.Height
- ( ( QuickRep1.Page.TopMargin
/QuickRep1.Page.Length
) * QuickRep1.Height //页头高度
+
( QuickRep1.Page.BottomMargin
/QuickRep1.Page.Length
) * QuickRep1.Height //页尾高度
)
- QRBand1.Height //标题1高度
- QRChildBand1.Height //标题2高度
) DIV QRSubDetail1.Height //每行高度
);
//每页行数=(报表的高度-上边界的高度-下边界的高度-页头1高度-页头2高度) DIV 每行高度
i:=1;
Sum1:=0;
Sum2:=0;
end;
哪里有QRBlank和QRGroup倥件?我怎么没找到
object frmR6: TfrmR6
Left = 394
Top = 273
BorderIcons = [biSystemMenu]
BorderStyle = bsSingle
Caption = '锣眀咎靡'
ClientHeight = 184
ClientWidth = 364
Color = clBtnFace
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Arial'
Font.Style = []
OldCreateOrder = False
Position = poMainFormCenter
Scaled = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 14
object Label3: TLabel
Left = 84
Top = 46
Width = 50
Height = 13
AutoSize = False
Caption = '秨﹍ら戳'
end
object Label4: TLabel
Left = 84
Top = 74
Width = 53
Height = 13
AutoSize = False
Caption = '挡ら戳'
end
object LbeginNo: TLabel
Left = 84
Top = 102
Width = 51
Height = 13
AutoSize = False
Caption = '秨﹍肚布'
end
object LendNo: TLabel
Left = 84
Top = 130
Width = 54
Height = 13
AutoSize = False
Caption = '挡肚布'
end
object RG1: TRadioGroup
Left = 3
Top = 3
Width = 66
Height = 140
ItemIndex = 0
Items.Strings = (
'ず眀'
'眀')
TabOrder = 0
end
object StaticText1: TStaticText
Left = 84
Top = 18
Width = 52
Height = 18
Caption = 'そ腹'
TabOrder = 1
end
object QRBlank: TQRBand
Left = 212
Top = 166
Width = 688
Height = 40
Frame.Color = clBlack
Frame.DrawTop = False
Frame.DrawBottom = False
Frame.DrawLeft = False
Frame.DrawRight = False
AlignToBottom = False
BeforePrint = QRBlankBeforePrint
Color = clWhite
ForceNewColumn = False
ForceNewPage = False
Size.Values = (
105.833333333333
1820.33333333333)
BandType = rbGroupFooter
end