quickrep打印問題(30分)

  • 主题发起人 主题发起人 wen_one
  • 开始时间 开始时间
W

wen_one

Unregistered / Unconfirmed
GUEST, unregistred user!
各位好大俠,如何在quickrep中實現多列先橫打再豎打呢,如
1,2
3,4
5,6
而不是
1 4
2 5
3 6
 
在TQuickRep的onNeedData事件中进行处理
参考一下(以前的帖子)
procedure TFormRepSm.QuickRep2NeedData(Sender: TObject;
var MoreData: Boolean);
var I:Integer;
begin
if not Datamodule1.Query_CKInquire.Eof then
moredata:=True
else
moredata:=false;
for I:= 1 to 2do
begin
case I of
1: begin
if Datamodule1.Query_CKInquire.Eof then
begin
QrLabel4.Caption:='';
QrLabel5.Caption:='';
QrLabel6.Caption:='';
QrLabel7.Caption:='';
QrLabel8.Caption:='';
end
else
begin
QrLabel4.Caption:=Datamodule1.Query_CKInquire.FieldByName('P_code).AsString;
QrLabel5.Caption:=copy(Datamodule1.Query_CKInquire.FieldByName('P_name').AsString,1,22);
QrLabel6.Caption:=FormatFloat('#,###',Datamodule1.Query_CKInquire.FieldByName('P_qty').AsFloat);
QrLabel7.Caption:=FormatFloat('#,###.00;;
',Datamodule1.Query_CKInquire.FieldByName('P_amt').AsFloat);
QrLabel8.Caption:=FormatFloat('#,###.00;;
',Datamodule1.Query_CKInquire.FieldByName('P_avg').AsFloat);
end;
end;
2: begin
if Datamodule1.Query_CKInquire.Eof then
begin
QrLabel19.Caption:='';
QrLabel20.Caption:='';
QrLabel21.Caption:='';
QrLabel22.Caption:='';
QrLabel23.Caption:='';
end
else
begin
QrLabel19.Caption:=Datamodule1.Query_CKInquire.FieldByName('P_code).AsString;
QrLabel20.Caption:=copy(Datamodule1.Query_CKInquire.FieldByName('P_name').AsString,1,22);
QrLabel21.Caption:=FormatFloat('#,###',Datamodule1.Query_CKInquire.FieldByName('P_qty').AsFloat);
QrLabel22.Caption:=FormatFloat('#,###.00;;
',Datamodule1.Query_CKInquire.FieldByName('P_amt').AsFloat);
QrLabel23.Caption:=FormatFloat('#,###.00;;
',Datamodule1.Query_CKInquire.FieldByName('P_avg').AsFloat);
end;
end;

end
Datamodule1.Query_CKInquire.Next;
end;
 
這個我在以前試過了,不行。
順便再提問一個問題,如何實現分頁打印呢?
 
我也有同感,如何实现文本打印的程序控制分页,?
 
//我有例子怎么发给你
//你在用两个QRLABEL就可以了,先将QRLABEL赋空。再将表往下移一笔记录就可以了。
procedure TForm1.DetailBand1BeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
begin
QRLabel2.caption := '';
if not ADOTable1.Eof then
begin
QRLabel1.Caption := ADOTable1.Fields[0].AsString ;
ADOTable1.next;
end;
if not ADOTable1.Eof then
begin
QRLabel2.Caption := ADOTable1.Fields[0].AsString ;
end;

end;
以下是全部代码。
 
//PAS
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
QuickRpt, Qrctrls, StdCtrls, Db, ADODB, ExtCtrls, Grids, DBGrids;
type
TForm1 = class(TForm)
QuickRep1: TQuickRep;
DetailBand1: TQRBand;
DataSource1: TDataSource;
ADOConnection1: TADOConnection;
ADOTable1: TADOTable;
Button1: TButton;
QRLabel1: TQRLabel;
QRLabel2: TQRLabel;
DBGrid1: TDBGrid;
procedure Button1Click(Sender: TObject);
procedure DetailBand1BeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
ADOTable1.Open;
ADOTable1.First;
QuickRep1.Preview;
end;

procedure TForm1.DetailBand1BeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
begin
QRLabel2.caption := '';
if not ADOTable1.Eof then
begin
QRLabel1.Caption := ADOTable1.Fields[0].AsString ;
ADOTable1.next;
end;
if not ADOTable1.Eof then
begin
QRLabel2.Caption := ADOTable1.Fields[0].AsString ;
end;

end;

end.


//DFM
object Form1: TForm1
Left = 192
Top = 107
Width = 544
Height = 375
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
PixelsPerInch = 96
TextHeight = 13
object QuickRep1: TQuickRep
Left = 40
Top = 224
Width = 794
Height = 1123
Frame.Color = clBlack
Frame.DrawTop = False
Frame.DrawBottom = False
Frame.DrawLeft = False
Frame.DrawRight = False
DataSet = ADOTable1
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial'
Font.Style = []
Functions.Strings = (
'PAGENUMBER'
'COLUMNNUMBER'
'REPORTTITLE')
Functions.DATA = (
'0'
'0'
#39#39)
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 = 40
Frame.Color = clBlack
Frame.DrawTop = False
Frame.DrawBottom = False
Frame.DrawLeft = False
Frame.DrawRight = False
AlignToBottom = False
BeforePrint = DetailBand1BeforePrint
Color = clWhite
ForceNewColumn = False
ForceNewPage = False
Size.Values = (
105.833333333333
1899.70833333333)
BandType = rbDetail
object QRLabel1: TQRLabel
Left = 40
Top = 16
Width = 58
Height = 17
Frame.Color = clBlack
Frame.DrawTop = False
Frame.DrawBottom = False
Frame.DrawLeft = False
Frame.DrawRight = False
Size.Values = (
44.9791666666667
105.833333333333
42.3333333333333
153.458333333333)
Alignment = taLeftJustify
AlignToBand = False
AutoSize = True
AutoStretch = False
Caption = 'QRLabel1'
Color = clWhite
Transparent = False
WordWrap = True
FontSize = 10
end
object QRLabel2: TQRLabel
Left = 240
Top = 16
Width = 58
Height = 17
Frame.Color = clBlack
Frame.DrawTop = False
Frame.DrawBottom = False
Frame.DrawLeft = False
Frame.DrawRight = False
Size.Values = (
44.9791666666667
635
42.3333333333333
153.458333333333)
Alignment = taLeftJustify
AlignToBand = False
AutoSize = True
AutoStretch = False
Caption = 'QRLabel2'
Color = clWhite
Transparent = False
WordWrap = True
FontSize = 10
end
end
end
object Button1: TButton
Left = 112
Top = 16
Width = 75
Height = 25
Caption = '预览'
TabOrder = 1
OnClick = Button1Click
end
object DBGrid1: TDBGrid
Left = 104
Top = 56
Width = 353
Height = 153
DataSource = DataSource1
TabOrder = 2
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'MS Sans Serif'
TitleFont.Style = []
end
object DataSource1: TDataSource
DataSet = ADOTable1
Left = 32
Top = 24
end
object ADOConnection1: TADOConnection
Connected = True
ConnectionString =
'Provider=Microsoft.Jet.OLEDB.4.0;Password="";User ID=Admin;Data ' +
'Source=C:/Program Files/Common Files/Borland Shared/Data/dbdemos' +
'.mdb;Mode=Share Deny None;Extended Properties="";Jet OLEDB:Syste' +
'm database="";Jet OLEDB:Registry Path="";Jet OLEDB:Database Pass' +
'word="";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=' +
'1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Tran' +
'sactions=1;Jet OLEDB:New Database Password="";Jet OLEDB:Create S' +
'ystem Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:' +
'Don'#39't Copy Locale on Compact=False;Jet OLEDB:Compact Without Rep' +
'lica Repair=False;Jet OLEDB:SFP=False'
LoginPrompt = False
Mode = cmShareDenyNone
Provider = 'Microsoft.Jet.OLEDB.4.0'
Left = 80
Top = 112
end
object ADOTable1: TADOTable
Connection = ADOConnection1
TableName = 'country'
Left = 64
Top = 208
end
end
 
wen_one@163.com
 
在TQuickRep的onNeedData事件中进行处理,
不过HY17的对不对没试过
 
后退
顶部