Simple Delphi Program to show usage of FastReport Delphi Component - Reporting Tool and Report Builder in Delphi

Simple Delphi Program to show usage of FastReport Delphi Component - Reporting Tool and Report Builder in Delphi

FastReport is a delphi component used as a reporting tool and report builder in delphi. FastReport is the most commonly and frequently used reporting tool in delphi. Here is a simple delphi program which will show you how to use fastreport reporting tool in delphi. This simple delphi program will show you how to generate report and print that report in delphi using fastreport reporting tool and report builder.

procedure MyForm.HowToUseFastReport;
begin
  try
    frxReport1.PrepareReport(true); //Prepare the report
    frxReport1.ShowPreparedReport; //Show the prepared report.
    frxReport1.PrintOptions.ShowDialog := False; //Do not show print dialog
    frxReport1.PrintOptions.Printer := YourPrinterName; //Assign Printer Name
    frxReport1.SelectPrinter; //Select this printer
    frxReport1.PrintOptions.Copies := NoOfCopies; //Assign number of copies to be printed
    frxReport1.Print; //Finally print
  except
    on E : Exception do
    begin
      ShowMessage('Error occured in function HowToUseFastReport: ' + E.Message);
    end;
  end;
end;

Explanation:

First of all you have to prepare report and then afterwards show the prepared report using ShowPreparedReport. Now the report will be shown. When you close the report next lines of code will be executed. If you do not want to see the report and just want to print it automatically just commnet the following line:

frxReport1.ShowPreparedReport; //Show the prepared report.