我用的FastReport 在直接打印的时候出现程序死了;但是我在打印之前先预览,再打印的时候就没有问题,下面是我写的代码,请高手指点一下
procedure Tfrm_report.btPrintClick(Sender: TObject);
// **** 直接打印
var
sReportfile:String;
begin
inherited;
sReportfile:= PApp_path+'reports\客户资料.frf';
if FileExists(sReportfile) then begin
frReport1.LoadFromFile(sReportfile);
frReport1.PrintPreparedReportDlg; //直接打印
end
else begin
Application.MessageBox('没有这个文件,可能报表文件已丢失!','提示信息',MB_OK);
Exit;
end;
end;procedure Tfrm_report.btPreviewClick(Sender: TObject);
// **** 打印预览
var
sReportfile:String;
begin
inherited;
sReportfile:= PApp_path+'reports\客户资料.frf';
if FileExists(sReportfile) then begin
frReport1.LoadFromFile(sReportfile);
frReport1.ShowReport;
end
else begin
Application.MessageBox('没有这个文件,可能报表文件已丢失!','提示信息',MB_OK);
Exit;
end;
end;
procedure Tfrm_report.btPrintClick(Sender: TObject);
// **** 直接打印
var
sReportfile:String;
begin
inherited;
sReportfile:= PApp_path+'reports\客户资料.frf';
if FileExists(sReportfile) then begin
frReport1.LoadFromFile(sReportfile);
frReport1.PrintPreparedReportDlg; //直接打印
end
else begin
Application.MessageBox('没有这个文件,可能报表文件已丢失!','提示信息',MB_OK);
Exit;
end;
end;procedure Tfrm_report.btPreviewClick(Sender: TObject);
// **** 打印预览
var
sReportfile:String;
begin
inherited;
sReportfile:= PApp_path+'reports\客户资料.frf';
if FileExists(sReportfile) then begin
frReport1.LoadFromFile(sReportfile);
frReport1.ShowReport;
end
else begin
Application.MessageBox('没有这个文件,可能报表文件已丢失!','提示信息',MB_OK);
Exit;
end;
end;
解决方案 »
- Delphi能不能处理IdHttp返回的PHP数组?
- 关于 with do 语句 (来者有分)
- 关于用Indy中的TIdDNSResolve组件获取主机IP地址的问题?
- 〖动态建树(TreeView),大家进来看看,帮帮忙!!〗
- 程序员应具备的素质!!
- 假设我不知道inttostr()这个函数!
- 想知道ComboBox的Text中的值是否存在于ComboBox的Items中,该如何实现。
- 讨论:中间层对象的粒度粗细问题?不知道用粒度这个词是否合适,具体请看内容
- 成都:诚聘delphi熟手
- 关于Delphi安装程序的设置
- 在fastreport中如何用memo显示空记录
- DELPHI处理数据库日期字段的问题
procedure Tfrm_report.btPrintClick(Sender: TObject);
// **** 直接打印
var
sReportfile:String;
begin
inherited;
sReportfile:= PApp_path+'reports\客户资料.frf';
if FileExists(sReportfile) then begin
frReport1.LoadFromFile(sReportfile);
frReport1.PrepareReport; //准备
frReport1.PrintPreparedReport('', 1, True, frAll); //打印
end
else begin
Application.MessageBox('没有这个文件,可能报表文件已丢失!','提示信息',MB_OK);
Exit;
end;
end;
我用frReport1.PrintPreparedReport('', 1, False, frAll); //打印
这样试也是先直接打印一份,再跳出打印对话框,按确定就会再次打印,当然取消就不打印
能不能直接打印一份后,不再跳出打印对话框,谢谢
frReport.Preview=nil;
frReport.SavePreparedReport('*.frf');//随便取个名字存一下
if frReport.PrepareReport then
frReport.PrintPreparedReport('',1,false,frAll);