用delphi 6 QuickReport如何打印这样的表格???(在线等待!!!!!!)(100分)

  • 主题发起人 主题发起人 tingchao
  • 开始时间 开始时间
T

tingchao

Unregistered / Unconfirmed
GUEST, unregistred user!
我的要求是这样子的.假如我记录集合中只有10条记录,但是我要打印固定有15行的表格,这样表格最后就有5个空行了,如何实现.
还有就是我要在一张打印纸中打印两个这样的表格,怎么实现.
假如我有20个记录,它就会自动分成两个表格.一个表格有15行数据,(填满).另一个表格有5个记录,还有就是有10个空行,怎么实现???
在线等哪.急啊.....哪位大侠能帮帮我啊....
谢谢!!!!!
 
我以前是这样做的 在打印前 用代码增加空记录 打印后立刻删除
 
你在底板上画表格线就行了。
 
QuickReport很久没用了
一般做法是建立临时表,不满15行的用Insert空行补满
如果希望每页显示15条数据的话,可以设置Page的Length属性,让它每页正好能显示15行,
 
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, QRCtrls, QuickRpt, ExtCtrls, DB, ADODB;
type
TForm1 = class(TForm)
ADOConnection1: TADOConnection;
ADODataSet1: TADODataSet;
ADODataSet1a: TStringField;
Panel1: TPanel;
QuickRep1: TQuickRep;
DetailBand1: TQRBand;
QRDBText1: TQRDBText;
Button1: TButton;
QRShape1: TQRShape;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure DetailBand1AfterPrint(Sender: TQRCustomBand;
BandPrinted: Boolean);
procedure QRDBText1Print(sender: TObject;
var Value: string);
procedure QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
procedure QuickRep1StartPage(Sender: TCustomQuickRep);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
i: integer;
begin
ADODataSet1.CreateDataSet;
ADODataSet1.Open;
for i := 1 to 9do
ADODataSet1.AppendRecord([inttostr(i)]);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
ADODataSet1.First;
try
QuickRep1.Preview
except;
end;
end;

procedure TForm1.DetailBand1AfterPrint(Sender: TQRCustomBand;
BandPrinted: Boolean);
begin
QuickRep1.Tag := QuickRep1.Tag + 1;
if ADODataSet1.RecNo = ADODataSet1.RecordCount then
begin
if QuickRep1.Tag < 9 then
ADODataSet1.Prior;
QRDBText1.Visible := false;
end;
end;

procedure TForm1.QRDBText1Print(sender: TObject;
var Value: string);
begin
if QRDBText1.Visible = false then
Value := '';
end;

procedure TForm1.QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
begin

QRDBText1.Visible := true;
end;

procedure TForm1.QuickRep1StartPage(Sender: TCustomQuickRep);
begin
QuickRep1.Tag := 0;
end;

end.


object Form1: TForm1
Left = 254
Top = 107
Width = 736
Height = 638
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
Scaled = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Panel1: TPanel
Left = 224
Top = 56
Width = 816
Height = 1145
BorderWidth = 10
Caption = 'Panel1'
TabOrder = 0
Visible = False
object QuickRep1: TQuickRep
Left = 59
Top = 115
Width = 794
Height = 1123
Frame.Color = clBlack
Frame.DrawTop = False
Frame.DrawBottom = False
Frame.DrawLeft = False
Frame.DrawRight = False
BeforePrint = QuickRep1BeforePrint
DataSet = ADODataSet1
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = []
Functions.Strings = (
'PAGENUMBER'
'COLUMNNUMBER'
'REPORTTITLE')
Functions.DATA = (
'0'
'0'
'''''')
OnStartPage = QuickRep1StartPage
Options = [FirstPageHeader, LastPageFooter]
Page.Columns = 1
Page.Orientation = poPortrait
Page.PaperSize = A4
Page.Values = (
100
2970
100
2100
100
100
0)
PrinterSettings.Copies = 1
PrinterSettings.Duplex = False
PrinterSettings.FirstPage = 0
PrinterSettings.LastPage = 0
PrinterSettings.OutputBin = Auto
PrintIfEmpty = True
SnapToGrid = True
Units = MM
Zoom = 100
object DetailBand1: TQRBand
Left = 38
Top = 38
Width = 718
Height = 115
Frame.Color = clBlack
Frame.DrawTop = False
Frame.DrawBottom = False
Frame.DrawLeft = False
Frame.DrawRight = False
AfterPrint = DetailBand1AfterPrint
AlignToBottom = False
Color = clWhite
ForceNewColumn = False
ForceNewPage = False
Size.Values = (
304.270833333333
1899.70833333333)
BandType = rbDetail
object QRShape1: TQRShape
Left = 6
Top = -2
Width = 371
Height = 117
Frame.Color = clBlack
Frame.DrawTop = False
Frame.DrawBottom = False
Frame.DrawLeft = False
Frame.DrawRight = False
Size.Values = (
309.5625
15.875
-5.29166666666667
981.604166666667)
Shape = qrsRectangle
end
object QRDBText1: TQRDBText
Left = 32
Top = 8
Width = 8
Height = 18
Frame.Color = clBlack
Frame.DrawTop = False
Frame.DrawBottom = False
Frame.DrawLeft = False
Frame.DrawRight = False
Size.Values = (
47.625
84.6666666666667
21.1666666666667
21.1666666666667)
Alignment = taLeftJustify
AlignToBand = False
AutoSize = True
AutoStretch = False
Color = clWhite
DataSet = ADODataSet1
DataField = 'a'
OnPrint = QRDBText1Print
Transparent = False
WordWrap = True
FontSize = 10
end
end
end
end
object Button1: TButton
Left = 96
Top = 216
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 1
OnClick = Button1Click
end
object ADOConnection1: TADOConnection
Left = 64
Top = 48
end
object ADODataSet1: TADODataSet
Parameters = <>
Left = 104
Top = 80
object ADODataSet1a: TStringField
FieldName = 'a'
Size = 100
end
end
end
 
谢谢大家的回答.不过我看过DELPHI自带的MEMOS中的报表,有个needdate事件,在这里只要写几行代码就可以了.我已经自己解决了.
还有就是想告诉大家一个事情就是,如果有碰到问题的话,先去找找看Memos中的例子,一般都会有觉得的方案的.
 
多人接受答案了。
 
后退
顶部