if frReport1.PrepareReport then frReport1.PrintPreparedReport('', 1, True, frAll);http://fastreport.free.fr/fastrpt6.htm
楼上说的对,但还要修改部分fastreport代码,否则会弹出打印机选择框 FR_View.pas的procedure TfrPreviewForm.PrintBtnClick(Sender: TObject); var Pages: String; begin if (EMFPages = nil) or (Printer.Printers.Count = 0) then Exit; with TfrPrintForm.Create(nil) do begin E1.Text := IntToStr(TfrReport(Doc).DefaultCopies); CollateCB.Checked := TfrReport(Doc).DefaultCollate; // if not TfrReport(Doc).ShowPrintDialog or (ShowModal = mrOk) then begin { if Printer.PrinterIndex <> ind then if TfrReport(Doc).CanRebuild then if TfrReport(Doc).ChangePrinter(ind, Printer.PrinterIndex) then begin TfrEMFPages(EMFPages).Free; EMFPages := nil; TfrReport(Doc).PrepareReport; Connect(Doc); end else begin Free; Exit; end;} if RB1.Checked then Pages := '' else if RB2.Checked then Pages := IntToStr(CurPage) else Pages := E2.Text; ConnectBack; TfrReport(Doc).PrintPreparedReport(Pages, StrToInt(E1.Text), CollateCB.Checked, TfrPrintPages(CB2.ItemIndex)); Connect(Doc); RedrawAll(False); end; Free; end; end;对于需要变动的标签,我用变量改不行,后来建一个临时表与这个标签关联,修改表中的数据就没什么问题了。
给你一端我的代码,参考一下吧。 DataModule1.frReport1.LoadFromFile('话单报表.frf'); if mainForm.CDS_callturn.RecordCount>0 then with TPVform.Create(self) do begin DataModule1.frReport1.Preview := frPreview1; if DataModule1.frReport1.PrepareReport then begin DataModule1.frReport1.ShowPreparedReport; frPreview1.Print; free; end; end;
if frReport1.PrepareReport then frReport1.PrintPreparedReport('', 1, True, frAll); 要在单元中uses fr_class.pas就没有问题了。
frReport1.PrintPreparedReport('', 1, True, frAll);http://fastreport.free.fr/fastrpt6.htm
FR_View.pas的procedure TfrPreviewForm.PrintBtnClick(Sender: TObject);
var
Pages: String;
begin
if (EMFPages = nil) or (Printer.Printers.Count = 0) then Exit;
with TfrPrintForm.Create(nil) do
begin
E1.Text := IntToStr(TfrReport(Doc).DefaultCopies);
CollateCB.Checked := TfrReport(Doc).DefaultCollate;
// if not TfrReport(Doc).ShowPrintDialog or (ShowModal = mrOk) then
begin
{ if Printer.PrinterIndex <> ind then
if TfrReport(Doc).CanRebuild then
if TfrReport(Doc).ChangePrinter(ind, Printer.PrinterIndex) then
begin
TfrEMFPages(EMFPages).Free;
EMFPages := nil;
TfrReport(Doc).PrepareReport;
Connect(Doc);
end
else
begin
Free;
Exit;
end;}
if RB1.Checked then
Pages := ''
else if RB2.Checked then
Pages := IntToStr(CurPage)
else
Pages := E2.Text;
ConnectBack;
TfrReport(Doc).PrintPreparedReport(Pages, StrToInt(E1.Text),
CollateCB.Checked, TfrPrintPages(CB2.ItemIndex));
Connect(Doc);
RedrawAll(False);
end;
Free;
end;
end;对于需要变动的标签,我用变量改不行,后来建一个临时表与这个标签关联,修改表中的数据就没什么问题了。
jpyc(智若愚):您的我还没去试过的,呵呵。
DataModule1.frReport1.LoadFromFile('话单报表.frf');
if mainForm.CDS_callturn.RecordCount>0 then
with TPVform.Create(self) do
begin
DataModule1.frReport1.Preview := frPreview1;
if DataModule1.frReport1.PrepareReport then
begin
DataModule1.frReport1.ShowPreparedReport;
frPreview1.Print;
free;
end;
end;
frReport1.PrintPreparedReport('', 1, True, frAll);
要在单元中uses fr_class.pas就没有问题了。