关于报表打印(急)
BS 2002-11-09 11:20:09 我用TQuickRep做了一个交费发票打印,也就是连续打印。
数据是手工的到的,不是数据集;
所以在TQuickRep上我用的是标签,再动态附值,不过在直接打印时且没有反映;
但是如果先预览,再在预览中打印且可以。不只什么原因?(100分)
因为我是生成一页打一页,所以让客户每次都要预览很不方便,想一次生成所有的页;再预览,可是我不知道怎样分页,请大侠指点(100分)?
打印代码:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Qrctrls, QuickRpt, ExtCtrls;
type
TfrmPrintSheet = class(TForm)
QuickRep5: TQuickRep;
DetailBand2: TQRBand;
QRShape53: TQRShape;
QRLabel1: TQRLabel;
QRLabel18: TQRLabel;
QRLabel65: TQRLabel;
QRLabel67: TQRLabel;
QRLabel71: TQRLabel;
QRLabel72: TQRLabel;
QRShape72: TQRShape;
QRShape98: TQRShape;
QRShape99: TQRShape;
QRShape100: TQRShape;
QRShape101: TQRShape;
QRShape102: TQRShape;
QRShape103: TQRShape;
QRLabel73: TQRLabel;
QRLabel74: TQRLabel;
kpUserID: TQRLabel;
kpUserAddress: TQRLabel;
kpUpCaseMoney: TQRLabel;
kpLowCaseMoney: TQRLabel;
kpOperator: TQRLabel;
QRShape105: TQRShape;
QRShape106: TQRShape;
QRShape107: TQRShape;
QRShape108: TQRShape;
QRShape111: TQRShape;
QRShape112: TQRShape;
QRShape113: TQRShape;
QRLabel87: TQRLabel;
kpPrintDate: TQRLabel;
QRLabel93: TQRLabel;
kpBankAccount: TQRLabel;
kpStartDate: TQRLabel;
kpUnPay: TQRLabel;
QRLabel95: TQRLabel;
QRLabel75: TQRLabel;
kpUserName: TQRLabel;
private
{ Private declarations }
public
{ Public declarations }
function kpPreview1(var PrintData:array of string):Boolean;//开平
end;
var
frmPrintSheet: TfrmPrintSheet;
implementation
{$R *.DFM}
function TfrmPrintSheet.kpPreview1(var PrintData:array of string):Boolean;
begin
result:=true;
try
kpUserID.Caption:=PrintData[0];
kpUserName.Caption:=PrintData[1];
kpBankAccount.Caption:=PrintData[2];
kpUserAddress.Caption:=PrintData[3];
kpStartDate.Caption:=PrintData[4];
kpUnpay.Caption:=PrintData[5];
kpUpCaseMoney.Caption:=PrintData[5];
kpLowCaseMoney.Caption:=PrintData[5];
kpOperator.Caption:=PrintData[6];
kpPrintDate.Caption:=PrintData[7];
QuickRep5.Print; // .Preview;
except
result:=false;
end;
end;
end.
调用代码:
procedure TMainForm.BankPrintClick(Sender: TObject);
var
varfile:TextFile;
UserInfo:string;
i:integer;
varData:array[0..7] of string;
begin
if OpenDialog1.Execute then AssignFile(varfile,OpenDialog1.filename) else exit;
try
reset(varfile);
while not eof(varfile) do
begin
readln(varfile,UserInfo);
for i:=0 to 6 do
begin
varData[i]:=Copy(UserInfo,1,pos(#9,UserInfo)-1);
delete(UserInfo,1,pos(#9,UserInfo))
end;
varData[7]:=DateTimeToStr(now);
if frmPrintSheet.kpPreview1(varData) then continue;
showmessage('打印错误,请检查打印机设置');
exit;
end;
closefile(varfile);
showmessage('打印完毕');
except
showmessage('读文件'+OpenDialog1.FileName+'出错');
closefile(varfile);
end;
end;