我用TQuickRep做了一个交费发票打印,也就是连续打印。
数据是手工的到的,不是数据集;
所以在TQuickRep上我用的是标签,再动态附值,不过在直接打印时且没有反映;
但是如果先预览,再在预览中打印且可以。不只什么原因?(100分)
因为我是生成一页打一页,所以让客户每次都要预览很不方便,想一次生成所有的页;再预览,可是我不知道怎样分页,请大侠指点(100分)?打印代码:
unit Unit2;
interfaceuses
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;
数据是手工的到的,不是数据集;
所以在TQuickRep上我用的是标签,再动态附值,不过在直接打印时且没有反映;
但是如果先预览,再在预览中打印且可以。不只什么原因?(100分)
因为我是生成一页打一页,所以让客户每次都要预览很不方便,想一次生成所有的页;再预览,可是我不知道怎样分页,请大侠指点(100分)?打印代码:
unit Unit2;
interfaceuses
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;
解决方案 »
- delphi编程中用了paradox数据库,然后编完后生成的可运行文件在别的机子上不能运行,因为没把数据库弄过去,该怎么解决,谢谢了!!!
- TreeView添加子节点问题
- 用DATABASE DESKTOP做的.DB数据,如何用命令的方式保存为EXCEL文件?
- 奇怪,我这句怎么通不过呢:if assigned(FChild)<>nil then
- 问一下了,怎么判断TSaveDialog等对话框执行后,按的是确定键还是取消键?
- FTP求助,8858...
- 在线给分,如何用dbedit,dbcombo来保存数据,删除数据
- 在其它机子上运行时提示找不到数据库别名(在线等)
- 如何监控一个文件被什么程序打开过?
- 高分求解!各位大侠:我有一款老式摄像头,现欲做为实时照片输入,但图像模糊。不知各位有何良策,能够弥补(如加入其他设备,或程序上)。
- 怎么实现在memo里按ctr+enter键后触发button的click事件。。
- 哪里可高速下载delphi7.0(西安)?
只修改你这个Unit2就可以了。保存PrintData,然后给相应的TQrLabel的Tag设值,都连接到一个函数,写上述代码就可以了。
还有PrintData是指一页的数据吗?
可不可以帮我在上边的代码里改
TfrmPrintSheet = class(TForm)
...
private
FPrintData: array of string;
...function TfrmPrintSheet.kpPreview1(PrintData:array of string):Boolean;
begin
FPrintData := PrintData;
QuickRep5.Print;
end;