⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 faq.txt

📁 FASTREPORT报表工具,可以迅速制作报表.
💻 TXT
📖 第 1 页 / 共 2 页
字号:
    ResultString := 'Search';
end;


===============================================================================
2.10. Can I run the FR designer as a MDI Child?

You can't - try to change the FR sources.


===============================================================================
2.11. How to work with TfrUserDataset?

(I want to print data from array/stringgrid/etc)

Look at demo FR\DEMOS\PRNGRID.


===============================================================================
2.12. Can I print the A3 report on two A4 papers?

No, you can't.


===============================================================================
2.13. How to print on Dot Matrix Printers?

If you want fast printing - export your report to txt and then print it:

frReport1.PrepareReport;
frReport1.ExportTo(frTextExport1, 'prn');


===============================================================================
2.14. How to make particular object non-printable, but visible in the preview?

Wait for FR3.0. 


===============================================================================
2.15. FR prints multi-page reports in the order 1,1,2,2. How to change it to 1,2,1,2?

If report has several pages, FR prints all records in the page1 and then all
records in the page2. If you want to change it, set the TfrReport.DataSet
property to main dataset and set the TfrReport.ReportType = rtMultiple.


===============================================================================
2.16. Can I assign other paper bin for the first page of the report?

If your report template has two or more pages, you can set individual paper bin
to each page. But if your report has one page (one page in the designer, I mean)
you can't change the paper bin of the first page in the prepared report.


===============================================================================
2.17. How to fax/email the prepared report?

a) faxing: install the fax software. It adds the "Fax" printer to your printer
list. Just select this printer in FR and print on it.
b) emailing: export the prepared report to one of the formats
(frp,txt,html,rtf etc) and send it as attachment (you may use WinAPI function
to send an email).


===============================================================================
2.18. How to change a query parameter from the script?

(may I write something like Query1.Params[0].Text := '10'?)

No, FR can't access query parameters. But you can assign a variable to the
parameter (in the parameters editor) and change this variable:

Query1.Close;
MyParam1 := '10';
Query1.Open;


===============================================================================
2.19. How to disable some report pages?

Add an empty dialog form to the report and write this in its OnActivate event:

begin
  Page2.Visible := False 
end


===============================================================================
2.20. How to determine that report was builded succesfully?

if frReport1.PrepareReport then // successfull, show it
  frReport1.ShowPreparedReport


===============================================================================
2.21. How to hide some buttons in the designer?

There are some things in the FR_Desgn.pas:

type
  TfrDesignerRestriction =
    (frdrDontEditObj, frdrDontModifyObj, frdrDontSizeObj, frdrDontMoveObj,
     frdrDontDeleteObj, frdrDontCreateObj,
     frdrDontDeletePage, frdrDontCreatePage, frdrDontEditPage,
     frdrDontCreateReport, frdrDontLoadReport, frdrDontSaveReport,
     frdrDontPreviewReport, frdrDontEditVariables, frdrDontChangeReportOptions);
  TfrDesignerRestrictions = set of TfrDesignerRestriction;

var
  DesignerRestrictions: TfrDesignerRestrictions;

Assign some flags to the DesignerRestrictions and call the designer.


===============================================================================
2.22. How to use own function?

Use TfrReport.OnUserFunction event. Here is simple example:

procedure TForm1.frReport1UserFunction(const Name: String;
  p1, p2, p3: Variant; var val: Variant);
begin
  if AnsiCompareText('SUMTOSTR', Name) = 0 then
    val := My_Convertion_Routine(frParser.Calc(p1));
end;

After this, you can use SumToStr function in any place of report
(in any expression or script).


(ok, but it works only for one TfrReport component. I want to use
my function everywhere (in all TfrReport components).

Make OnUserFunction event handler common for all components. If you can't do
this, you should create the function library:

type
  TMyFunctionLibrary = class(TfrFunctionLibrary)
  public
    constructor Create; override;
    procedure DoFunction(FNo: Integer; p1, p2, p3: Variant;
      var val: Variant); override;
  end;

constructor TMyFunctionLibrary.Create;
begin
  inherited Create;
  with List do
  begin
    Add('DATEPROPIS');
    Add('SUMPROPIS');
  end;
end;

procedure TMyFunctionLibrary.DoFunction(FNo: Integer; p1, p2, p3: Variant;
  var val: Variant);
begin
  val := 0;
  case FNo of
    0: val := My_DateConvertion_Routine(frParser.Calc(p1));
    1: val := My_SumConvertion_Routine(frParser.Calc(p1));
  end;
end;

To register function library, call
frRegisterFunctionLibrary(TMyFunctionLibrary);
To unregister library, call
frUnRegisterFunctionLibrary(TMyFunctionLibrary);


(how I can add my function to function list (in expression builder)?

Use frAddFunctionDesc procedure (FR_Class unit):

frAddFunctionDesc(FuncLib, 'SUMTOSTR', 'My functions',
  'SUMTOSTR(<Number>)/Converts number to its verbal presentation.');

Note: "/" symbol is required! It separates the function syntax from its
description.
FuncLib is reference to your function library (can be nil if you don't use
the function library). When function library is unregistered, all its
function will be automatically removed from the function list.


===============================================================================
2.23. How to fill the data dictionary programmatically?

All variables and categories from data dictionary stored in
TfrReport.Dictionary.Variables.

with frReport1.Dictionary do
begin
  // creating category (space in category name required!)
  Variables[' New category'] := '';
  // creating variables
  Variables['New Variable'] := 'CustomerData.Customers."CustNo"';
  Variables['Another Variable'] := 'Page#';
end;


===============================================================================
2.24. I don't want to show some datasets in the data dictionary and in the report.

Use TfrReport.Dictionary.DisabledDatasets:

with frReport1.Dictionary do
begin
  // turn of this dataset
  DisabledDatasets.Add('CustomerData.Bio');
  // or, turn off entire datamodule/form
  DisabledDatasets.Add('CustomerData*');
end;


===============================================================================
2.25. How to pass a value to the report?

There are several methods to do this. First is to use global object
frVariables (defined in FR_Class unit):

frVariables['My variable'] := 10;

This code creates a new variable with 'My variable' name and value = 10.
This method is best to pass static data to the report.

Second method is to use the TfrReport.OnGetValue event. You can use this
method to pass dynamic data, i.e. data that changes from record to record.

procedure TForm1.frReport1GetValue(ParName: String; var ParValue: Variant);
begin
  if ParName = 'MyField' then
    ParValue := Table1MyField.Value;
end;

Finally, third method is to define variable from dictionary programmatically:

with frReport1.Dictionary do
begin
  Variables['MyVariable'] := 'CustomerData.Customers."CustNo"';
  Variables['Another Variable'] := '10';
end;


(can I pass data from report to the program?)

Use frVariables object. If you write the following code in any script:

MyVariable := 10

then in your program you can use this code to retrieve MyVariable value:
v := frVariables['MyVariable'];


===============================================================================
2.26. How to make the TChart with several series?

You can't do this in designer. You need to write some code in Delphi.
Create TChart or TDBChart, fill it out; put the empty TfrChartView to the report;
write the following code in the TfrReport.OnBeforePrint event handler:

if View.Name = 'Chart1' then
  TfrChartView(View).AssignChart(your_Delphi_chart)


===============================================================================
2.27. How to switch pages in the designer?

Just drag the page tab on a new place.


===============================================================================
2.28. I want to show variables and data fields in one insert dialog.

Set the TfrReport.MixVariablesAndDBFields := True. All data fields and
variables now accessible in the "Insert data field" dialog.


===============================================================================
2.29. How to hide "export options" dialog?

Set all necessary properties of the export component (TfrTextExport, for example)
and disable the dialog by setting ShowDialog property to False.


===============================================================================
2.30. I store my reports in a BLOb. How to change the "Open/Save" dialogs in the designer?

Look at TfrDesigner component. It has necessary events: OnLoadReport and
OnSaveReport. Here is a small example:

procedure TForm1.frDesigner1LoadReport(Report: TfrReport;
  var ReportName: String; var Opened: Boolean);
begin
  with MyOpenDialog do
  begin
    Opened := ShowModal = mrOk;
    if Opened then
    begin
      Report.LoadFromBlobField(...);
      ReportName := ...;
    end;
  end;
end;

procedure TForm1.frDesigner1SaveReport(Report: TfrReport;
  var ReportName: String; SaveAs: Boolean; var Saved: Boolean);
begin
  if SaveAs then
    with MySaveDialog do
    begin
      Saved := ShowModal = mrOk;
      if Saved then
      begin
        Report.SaveToBlobField(...);
        ReportName := ...;
      end;
    end
  else
    Report.SaveToBlobField(...);
end;


===============================================================================
2.31. How to access to the report object from Delphi?

FR objects is not a components and can be accessed this way:

var
  t: TfrMemoView;
begin
  t := TfrMemoView(frReport1.FindObject('Memo1'));

  if t <> nil then
    t.Memo.Text := 'FastReport';
// or this:
  if t <> nil then
    t.Prop['Memo'] := 'FastReport';
end;


===============================================================================
2.32. How to define own hotkeys in the TfrPreview?

TfrPreview component has a property Window: TForm. You can assign your event
handler to the TfrPreview.Window.OnKeyDown.


===============================================================================
2.33. How to print a report without previewing it?  

This way:

if frReport1.PrepareReport then
  frReport1.PrintPreparedReport('', 1, True, frAll);
  // or
  frReport1.PrintPreparedReportDlg;


===============================================================================
2.34. How to print a picture that stored in a file?

a) use TfrReport.OnBeforePrint event:

if View.Name = 'Picture1' then
  TfrPictureView(View).Picture.LoadFromFile(...) or
                              .Assign or
                              .everything_what_you_want

b) in the script:

begin
  Picture1.LoadFromFile(filename)
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -