Fastreport Use Tips

Source: Internet
Author: User
1. In FastReport, if you want to access the objects in the report?
You can use the findobject method.
TfrxMemoView(frxReport1.FindObject(‘memo1‘)).Text:=‘FastReport‘;
2. How to use superscripts and subscripts in FastReport?
Set frxmemoview.allovehtmltags: = true; enter the following in text
Superscript: mm < sup > 2 < / sup >
The following table: K < sub > 6 < / sub >
You can use other HTML tags, for example.
3. How to print the total number of pages in FastReport?
After setting the report twice, add the contents in quotation marks: "page [total pages] of [total pages]"
4. How to dynamically add variables and variable groups to FastReport?
Create variable group name
Frxreport1. Variables. Add. Name: = '+ variable group name;
Create variable name
Frxreport1. Variables. Addvariable ('group name, if it is a non saved group or empty, it is the default group, which is not required here
Space ', variable name, initial value of variable);
For example, to establish variable group yuan, two variables Yuan1, Yuan2, then
Frxreport1. Variables. Add. Name: = 'Yuan' notice the space before it
Frxreport1.variables.addvariable ('yuan ', Yuan1, initial value)
Frxreport1.variables.addvariable ('yuan ', Yuan2, initial value)
5. How to add custom functions to FastReport?
FastReport can add the required functions to realize specific functions. The process is:
1) Add functions to the report.
Frxreport1. Addfunction ('full function declaration ');
If there is a custom function, getname (old: String): string; this function obtains another return value through a field in the dataset.
Then the statement is: frxreport1. Addfunction ('function getname (old: String): string; ');
2) Functions are used in scripts.
Use custom functions in scripts or reports, just like other FastReport built-in functions.
3) Functions are processed in the program.
The use function is implemented through the onuserfunction function function of frxreport1.
The onuserfunction is declared as follows: function (constmethodname: string; VAR params: variant): variant;
For example, the above function must have a function, which is the implementation part of getname. If there is a function implemented in the program.
Function realgetname (old: String): string; this function name doesn't matter, it can also be getname.
In the event processing of onuserfunction, the following code can be used to complete the use of custom functions in reports.
if CompareText(MethodName,‘GetName‘)=0 thenResult:=RealGetName(VarToStr(Params[0]));
I usually use comparetext to compare function names, because I found two versions of FastReport, one is
Methodname has been automatically changed to lowercase. One is that it has been automatically changed to uppercase. So compare it with comparetext,
There will be no mistake.
If there are multiple parameters, pass params [0] and params [1] in turn, and keep the order consistent.
Note here that if the parameter is a pointer, you cannot directly use pointer (integer (params [0]). Because the actual transmission
The integer value of the pointer is passed. You can use pointer (strtoint (vartostr (params [0])).
6. How to share tfrxreport and tfrxdbdataset in FastReport?
In a program, no matter how large the program is, as long as the printing or preview is in mode, you can share a tfrxreport
Variable and several tfrxdbdatasets. However, pay attention to the steps to complete a report program, mainly the following steps
1) Clear the report to get a new report content.
Frxreport1.clear。
2) Set the alias of the tfrxdbdataset to be used. If you don't need to, you can omit this step, but it is generally better for different reports to use No
The same alias.
Note that this step is before loading the report file, because the alias information is included in the general design of the report file.
Frxdbdataset1. Username: = alias;
3) Load a report or dynamically create a tfrxreportpage.
Frxreport1.loadfromfile (the full file name of the report file);
4) Associate tfrxdbdataset with tdataset, and set which tfrxdbdataset to use.
Frxreport1. Datasets. Clear; / / clear the original dataset first
Frxdbdataset1. Dataset: = dataset1; / / Associate FastReport's components with tdataset data set.
Frxreport1. Datasets. Add (frxdbdataset1); / / load the associated tfrxdbdataset into the report.
After these steps, you can use the common report component as if you were using a tfrxreport alone
7. How to use scripts in FastReport and variables in scripts?
Many times, we want to put the control over reports into the script of reports. Usually, I do this for two reasons:
1) Different settings can be used according to the changes of field contents, because if you want to achieve this function in the program, you have to use
Custom function, function implementation to be put in the program, function may need to pass many parameters, inefficient.
2) Putting the control of different reports into scripts can realize the modularization of reports. The program simply sets the relationship between data sets,
And load the report file on the hard disk. Different implementation methods and display methods of different reports are put into the report file. The program is simple
, easy to maintain, easy to upgrade.
Of course, such a disadvantage is that the alias of the dataset when the report is loaded in the program must be the same as the alias when the report is designed.
There is not much difference between the use of scripts and the use of normal programs, that is, just like a normal program, it can reference the name of the control.
But pay attention to the use of variables. You need to enclose the variable name or expression with < >.
Realize the number of pages for printing group. The basic principle is:
But pay attention to the use of variables. You need to enclose the variable name or expression with < >.
Realize the number of pages for printing group. The basic principle is:
1) You must use the second pass report, because the total number of pages calculated by FS requires the second pass report.
2) In the first report, before groupband is printed, an integer array variable is dynamically created to hold the last grouped
The total number of pages.
3) In the last report, tfrxmemove, which displays the number of grouped pages, gets the data in the array, but the last group
There will be no total number, which can be obtained by subtracting the number of pages saved in the groupband event from the total number of pages.
4) The code deals with one page with multiple groups and a group of multiple page printing group headers. You can see the code description of these special processes

5) I specially used tfrxmeoview to display these data in the group footer and footer, indicating the display in different situations.
8. How to change the content of tfrxmeoview according to the field name in the script in FastReport?
Suppose there is a data table "user", the field ID is the user ID, the name is the user name, which is required during printing. If the user name is empty, then
If "no user name" is printed, otherwise "user name: actual user" will be printed out, you can use the
Write the following script in the onafterdata event.
if<frxDBDataSet1."Name">=‘‘ then
Memo 2. Text: = 'no user name‘
Else
Memo 2. Text: = 'user name: [frxdbdataset1. "Name"]‘
Memo 2 is the tfrxmeview control that places user name data.
Note here that to access variables in a script, you need to include variables with < >.
9. How to dynamically adjust the height in FastReport?
I often use the following functions to dynamically adjust the height of band and tfrxmemoview. It should be noted that:
The function can only adjust the last line of multiple lines in a band. If there is only one line (which should be in most cases), it doesn't matter
, and this is under the premise that the width has been fixed. Write in the onbeforeprint event of the band you want to adjust the height
Setmemo (sender); with the following code, you can paste it into the code page.
The following code can also be evolved to achieve dynamic width. I have judged whether tag is 7635 in many places, because I often need to
Call one of these functions separately.
//7635 is a reserved number, which means no adjustment is made. It is usually used at the top of multiple lines
function Biger(Old:Extended):Integer;
Begin
Result:=Trunc(Old);
if Frac(Old)>0 then
Result:=Result+1;
End;
procedure JustHeight(Sender:TfrxComponent);
Var
RealHeight:Integer;
Begin
RealHeight:=Biger(TFrxMemoView(Sender).CalcHeight+TFrxMemoView(Sender).Top);
ifBiger(TfrxBand(Sender.Parent).Height)<RealHeight then
Begin
//If the height of the memo is less than band but the calculated height is greater than band, it will be adjusted in the function of adjusting band
TfrxBand(Sender.Parent).Height:=Biger(RealHeight);
JustBandHeight(Sender.Parent);
End
Else
TfrxMemoView(Sender).Height:=TfrxBand(Sender.Parent).Height
-TfrxMemoView(Sender).Top;
End;
procedureJustBandHeight(Sender:TfrxComponent);
Var
I:Integer;
Begin
for I:=0 to Sender.Objects.Count-1 do
if TObject(Sender.Objects.Items[I]) isTFrxMemoView then
ifTFrxMemoView(Sender.Objects.Items[I]).Tag=7635 then Continue
Else
//If it's small, it can't be changed
ifBiger(TfrxMemoView(Sender.Objects.Items[I]).Height+
TfrxMemoView(Sender.Objects.Items[I]).Top)<>Biger(TfrxBand(Sender).Height)then
TfrxMemoView(Sender.Objects.Items[I]).Height:=
Biger(TfrxBand(Sender).Height-TfrxMemoView(Sender.Objects.Items[I]).Top);
End;
procedure JustMemo(Sender:TfrxComponent);
Begin
if not Engine.FinalPass then Exit;
if Sender.Tag<>7635 then
JustHeight(Sender);
End;
procedure SetMemo(Sender:TfrxComponent);
Var
I:Integer;
Begin
for I:=0 to Sender.Objects.Count-1 do
if TObject(Sender.Objects.Items[I]) isTFrxMemoView then
ifTfrxMemoView(Sender.Objects.Items[I]).Tag<>7635 then
TfrxMemoView(Sender.Objects.Items[I]).OnAfterData:=‘JustMemo‘;
End;
10. How to implement template printing in FastReport?
The paper is continuously serrated and printed. Similar to the invoice of the communication company, the customer sales record is designed here.
The customer has two requirements:
1. Because the printed paper is printed and the detail record only has 8 lines, if the detail record is less than 8 lines, the company name will be
. the sales record is printed on the top, and the information of the next company is printed on the next page instead of the next page (ha ha, yes, such as
If they are connected, the printing list will lose its meaning.)
2. If the sales record has more than 8 lines, the sales record starting from line 9 will be printed on the next page (the so-called next page is actually a zigzag page
The next * of the division, is it more appropriate to call "the next part" , and the title (i.e. company name) should also be marked (if not
It may be confused after tearing it off. I don't know which company this page belongs to.)
Should the standard statement of problem description be called "print fixed line" or "force page change"?
Answer: the question of printing the head of each page is to print the band containing the company name repeatedly. Property.
Check it.
As for fixed lines, in fact, when designing template printing, the page size is fixed, and the height of each line is also fixed. Header and page
The foot is also fixed, so the number of lines that can be printed in the report designed naturally is the 8 lines you require. It doesn't need anything at all
Change pages. Because according to the paper will automatically page. All you have to do is design the paper size and layout, and then you have to print
It's the simplest type of printing, not too complicated to think about.
11. How to realize continuous printing in FastReport?
Many people think that FR can't achieve continuous printing. They think that they can only call the printing function through their own writing function to achieve continuous printing
At the same time, the implementation is very simple. You can even set the printing settings in your program
It is easy for the customer to choose whether to print continuously, and the rest can remain unchanged.
function PelsTomm(Pels:Extended):Extended;
Begin
Result:=Pels/Screen.PixelsPerInch*25.4;
End;
procedurePrintSerial(Frx:TFrxReport;SequencePage:Byte=0);
Var
P:TfrxReportPage;
R,R1:Extended;
Begin
{must be a double pass report, otherwise the total number of pages cannot be calculated.
The following method only applies if there is no footer, because if there is one
Freespace is always 0. You can use report feet instead.
Because it is continuous printing, it can also be regarded as only one page, and the report footer is equivalent to the footer}
if not Frx.Engine.DoublePass then Exit;
//Sequencepage refers to the page to be printed continuously. The normal report is 0
P:=TfrxReportPage(Frx.Pages[SequencePage]);
R1:=P.TopMargin+P.BottomMargin;
while Frx.PrepareReport do
Begin
if (Frx.Engine.TotalPages<=1) thenBreak;
R:=Pelstomm(Frx.Engine.TotalPages*Frx.Engine.PageHeight-
Frx.Engine.FreeSpace)+R1;
P.PaperHeight:=R;
End;
{you must use the above loop code to get the exact white space
You cannot get a blank area by calculating the total number of pages minus the margins of each page
Because if you encounter a record that is too wide, resulting in a page change, it is not accurate. }
R:=Pelstomm(Frx.Engine.TotalPages*Frx.Engine.PageHeight-
Frx.Engine.FreeSpace)+R1;
P.PaperHeight:=R;
End;
Call printserial before previewing or printing.
12. How to specify the printer name in the program?
Frxreport1. Report. Printoptions. Printer: = 'printer name';
13. How to print directly with printer?
implementation
uses Printers;
{$R *.dfm}
procedure TForm1.Button1Click(Sender:TObject);
Begin
Printer. Printerindex: = 0; {network printers should also be installed in your local operating system. Use order directly
Try it.
Printers. Printer. Setprinter ('hp1020 ',' hp1020 ',' LPT1 ', 0); {printer name, driver, port, etc,
Self check, I used virtual printer to test}
Printers.Printer.BeginDoc;
Printers. Printer. Canvas. TextOut (10,10, 'print this line');
Printers.Printer.EndDoc;
End;
14. How to print blank space?
Add the code to the OnBeforePrint event at the Band where the report is printed:
while FreeSpace > 20 do
ShowBand(Child1)
15. How to print the specified number of lines and then change pages?
Write the code in the onbeforeprint event in the master band:
Var
vLineCount: integer;
Begin
vLineCount := vLineCount + 1;
if vLineCount = 10 then
Begin
vLineCount := 0;
NewPage;
End;
End;
16. How to display data as percentage in fastport
Displayformat property, in which the kind you set to fknumeric, formatstr
[<frxDBDataset1."sjl">*100#n%2.2f]%”。
17. How does FastReport print blank rows in table format?
Var
Pageline: integer; / / print to the next line on the page
Pagemaxrow: integer = 15; / / set the number of columns per page
procedure MasterData1OnBeforePrint(Sender:TfrxComponent);
Begin
PageLine := <Line> mod PageMaxRow;
if(PageLine = 1) and (<line> > 1) then
Engine.newpage;
child1.visible := False;
End;
//Footer1 height set to 0
procedure Footer1OnBeforePrint(Sender:TfrxComponent);
Var
I:integer;
Begin
i:= iif(PageLine=0, PageMaxRow, PageLine);
child1.visible := True;
while i < PageMaxRow do
Begin
I:= I + 1;
Engine. Showband (Child1); / / print blank form
End;
child1.visible := False;
End;
Begin
End.
========================================================================
early version
----------------Use custom functions----------------------------------------
Q: How can I add my custom functions?
A: Use the tfrreport.onuserfunction event. Here is a simple example:
procedureTForm1.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;
You can then use the sumtostr function anywhere in the report (any expression or script).
Q: But it only works in a tfrreport component. But I want to be anywhere (in all the tfrreport components)
My custom function used?
A: Make the onuserfunctionevent handle a common handle to all components. If you can't do that, you need to create
Build 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(‘DATETOSTR‘);
Add(‘SUMTOSTR‘);
End;
End;
procedureTMyFunctionLibrary.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 a library, call
frRegisterFunctionLibrary(TMyFunctionLibrary);
To unload a library, call
frUnRegisterFunctionLibrary(TMyFunctionLibrary);
Q: How can I add my functions to the list of functions (with expression builder)?
A: Use the fraddfunctiondesc procedure (in the fr'u class cell):
frAddFunctionDesc(FuncLib, ‘SUMTOSTR‘, ‘Myfunctions‘,
‘SUMTOSTR(<Number>)/Converts number toits verbal presentation.‘);
Note: the '/' sign is required! It separates function syntax from its description.
Funclib is declared as your own function library (you can set it to nil if you don't use it). When the function library is not registered
All its functions are automatically removed from the list of functions.
----------------Using variables-------------------------------------
Q: How do I program to fill in the list of variables (in the data dictionary)?
A: All variables and classifications in the data dictionary are stored in tfrreport.dictionary.variables
with frReport1.Dictionary do
Begin
//Create category (name is blank)
Variables[‘ New category‘] := ‘ ‘;
//Create variables
Variables[‘New Variable‘] := ‘CustomerData.Customers."CustNo"‘;
Variables[‘Another Variable‘] := ‘Page#‘;
End;
Q: I defined string variables:
with frReport1.Dictionary do
Variables[‘Month‘] := ‘March‘;
But when I run the report, there is an error. Why?
A: Because FastReport assumes that the string variable value in the data dictionary is an expression, it needs to be analyzed and evaluated.
Other methods can be used:
with frReport1.Dictionary do
Variables[‘Month‘] := ‘‘‘‘ +‘March‘ + ‘‘‘‘;
Or, use frvariables to transfer fixed data to the report.
Q: I don't want to show some datasets in the data dictionary?
A: Use tfrreport.dictionary.disableddatasets:
with frReport1.Dictionary do
Begin
//Close the dataset
DisabledDatasets.Add(‘CustomerData.Bio‘);
//Or, close the entire data module / form
DisabledDatasets.Add(‘CustomerData*‘);
End;
Q: How do I transfer data to reports?
A: There are several ways to implement it. The first is to use the global object frvariables (defined in the fr'u class cell):
frVariables[‘My variable‘] := 10;
This code creates a variable named "my variable" with a value of 10. This is the best report for transferring fixed data
Method.
The second method is to use the tfrreport.ongetvalue event. This can be used to transfer dynamic data, records, etc

procedure TForm1.frReport1GetValue(ParName:String; var ParValue: Variant);
Begin
if ParName = ‘MyField‘ then
ParValue := Table1MyField.Value;
End;
Finally, the third method is to define variables in the data dictionary by programming (refer to previous problems):
with frReport1.Dictionary do
Begin
Variables[‘MyVariable‘] :=‘CustomerData.Customers."CustNo"‘;
Variables[‘Another Variable‘] := ’10’;
End;
Q: Can I transfer data between reports and programs?
A: Use the frvariables object. If you write the following code in the script of any object in the report:
MyVariable := 10
Then, in your program, you can use the following code to get the value of myvariable:
v := frVariables[‘MyVariable‘];
----------------Script (FastReport Pascal)---------------------------------
Q: Can scripts be used in band?
A: Of course. Select band and press Ctrl + enter or select the "on before print" attribute in the object browser.
Q: Can scripts be used in report pages?
A: Of course. Select the page (click in the space), and then select the "on before print" property in the object browser. If this
Page is a dialog form, so this property is "onactivate"
Q: I have two objects: Memo1 and Memo2.. Can I call Memo2's properties and methods in Memo1 script?
A: Of course, for example, you can do this: object name. Property name
Q: What properties of an object can I use in a script?
A: Almost all the properties you can see in the object browser. For example, you can use font. Name, font. Size, and so on to access
Font properties.
----------------Other problems--------------------------------------------
Q: How to change the order of a page in a multi page report?
A: Drag the page label to the destination.
Q: I want to see all the fields and variables. Do I want to use list to implement it in the report?
A: Set tfrreport.mixvariablesandbfields: = true. All data fields and variables can be inserted in the
Enter data fields dialog box is accessible.
Q: I don't want to display the import Options dialog?
A: Set all the necessary options in the import component (for example, tfrtextexport), and then set the ShowDialog property to
False to close this dialog box.
Q: Why does the totalpages variable not work? It always returns 0
A: Set the two pass option in your report. To set it, you need to open the
Report options dialog box.
Q: I use blob fields to store my reports. When I run report designer, it displays my report unnamed?
A: Before running report designer, do this:
frReport1.FileName := ‘Name of my report‘;
Q: Do I want to redefine the functions of the open and save buttons in report designer?
A: View the tfrdesigner component. It has several required events: onloadreport and
Onsavereport. Here is a short code example:
procedureTForm1.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;
procedureTForm1.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;
Q: In QR, I can write the following code: qrlabel1. Caption: = 'some text'. I can do this with fr
Do you?
A: The fr object is not a component (it is not like QR or RB). However, using the tfrreport.findobject method, you can use the
Object name found the object.
Var
t: TfrMemoView;
Begin
t :=TfrMemoView(frReport1.FindObject(’Memo1’));
if t <> nil then
t.Memo.Text := ’FastReport’;
End;
Q: Do I want to customize hotkeys in user preview (tfrpreview component)?
A: This component has a window: tform property. Specify the custom handle to window.onkeydown property
Q: Fast report 2.4 can't load freereport 2.21 file?
A: This only requires changing the first byte of the report file using a hexadecimal number, and then modifying the following section in the source code. In these repairs
After the change, load the report and save it. Finally, return to the source code
FR_Class:
function ReadString(Stream: Tstream):String;
Begin
{ if frVersion >= 23 then}
Result := frReadString(Stream) {else
Result := frReadString22(Stream);}
End;
procedure ReadMemo(Stream: Tstream; Memo:Tstrings);
Begin
{ if frVersion >= 23 then}
frReadMemo(Stream, Memo){ else
frReadMemo22(Stream, Memo);}
End;
FR_Utils:
procedure frReadMemo(Stream: Tstream; l:Tstrings);
Var
S: String;
B: Byte;
N: Word;
Begin
L.Clear;
l.Text := frReadString(Stream); exit;
Stream.Read(n, 2);
if n > 0 then
Repeat
Stream.Read(n, 2);
SetLength(s, n);
Stream.Read(s[1], n);
L.Add (s);
Stream.Read(b, 1);
Until B = 0
Else
Stream.Read(b, 1);
End;
function frReadString(Stream: Tstream):String;
Var
S: String;
N: Integer;
B: Byte;
Begin
Stream.Read(n, 4);
SetLength(s, n);
Stream.Read(s[1], n);
if (n > 0) and (s[n] = #$0A) then
SetLength(s, n - 2);
// Stream.Read(b, 1);
Result: = s;
End;
Q: How not to print report in print preview?
A: Here is a code:
frReport1.PrepareReport;
frReport1.PrintPreparedReport(‘‘, 1, True,frAll);
or
frReport1.PrintPreparedReportDlg;
Q: I want to rotate the picture in the report. The problem is that this image was generated by my application. Is there a way to print
Load this picture into the report?
A: Use the tfrreport.onbeforeprint event:
if View .Name = ‘Picture1‘ then
TfrPictureView(View).Picture.LoadFromFile(… Or
.Assign or
Anything you want to do
FastReport strategy
//A case study of the design of overprint behavior
1、 Defining variables
Taoda 0 is set type 1 not set type
Cpage system variable page#
Total number of pages of the cappage system variable
2、 Write in tfrpage.onbeforeprint event
{
ifTaoDa = ‘0‘ then
Begin
Title. Visible: = false; / / if you do not need to print, set visible to false;
Danweiv. Frameyp: = 0; / / the setting of frameyp is 0 for only printing data without printing border;
...
End;
I: = 0; / / define a variable and initialize it.
}
2、 Write in the main item data. Onbeforeprint event
{
ifTaoDa = ‘0‘ then
Begin
I:= I + 1;
bm.memo := i;
if(i > 5 ) then
if ((i-1) mod 6 ) = 0 then newpage;
End;
}
3、 Write in the main key. Onbeforeprint event
{
J: =i mod 6;
if j<> 0 then
Begin
for k := j to 5 do
Begin
Showband (Child1); / / Child1 is the name of the child with blank lines
End;
End;
}
4、 Column foot. Onbeforeprint event
{
ifcpage <> capage then
Begin
Shi. Memo: = '; / / ten
Bai. Memo: = '; / / hundred
Qian. Memo: = '; / / thousand
Wan.memeo: = '; / / ten thousand
End
Else begin
shi.memo := v1;
bai.memo := v2;
qian.memo := v3;
wan.memo := v4;
End;
}
This code is used to control the display of the total amount on the last page when there are multiple pages.
Where: V1, V2, V3, V4 are custom variables.
Report structure composition:
Column header / / draw the report header
Master data / / the data displayed will be bound to the data source
Main item foot / / nothing to put, only to control visible: = false;
Sub / / draw a blank line to display the component
Column footer / / displays the total amount and quantity
Footer / / shows the number of pages
Call method:
Frreporta.loadfromfile (s); s is the file
frReportA.Dictionary.Variables[‘taoda‘]:=‘1‘;
Query
Print:
frReportA.PrepareReport;
frreportA.PrintPreparedReport(‘‘,1,true,frall);
Preview:
frReportA.ShowReport;
FastReport printing CXGRID data
Used to FastReport, I don't want to use other print components. There is no good way and routine to print the data after CXGRID filter with FastReport. See the description of taking out the filer text of CXGRID and assigning it to dataset. It's too troublesome to test specifically. Such a famous component must have a way to solve this problem. So today, I went to dev Express English website to browse and search for it. Unexpectedly, there were more than n questioners who asked about this problem. After seeing several of these problems, they finally solved them.
The following methods can be used to solve this problem:
1. Set the datacontroller.filter.autodatasetfilter property of view to true.
This method requires dataset support to set.
2. Write the following code in checkeovevent of frdbdataset of FastReport:
EOF := frUserDataset1.RecNo >=Grid.ViewData.RecordCount;
Write the code in getValue event of frreport:
if ParName=‘Field1‘ then
ParValue :=Grid.ViewData.Records[frDataset1.RecNo].Values[2]);
This code can also be written as follows:
ParValue:=Grid.ViewData.Records[frDataset1.RecNo].Values[View.GetColumnByFieldName(ParName).Index]);
ReportMachine
1. How to use code to specify printer?
RMReport1.LoadFromFile(‘Untitled.rmf‘);
rmreport1.PrinterName:=‘\\192.168.10.1\HP LaserJet 1022‘;
FastReport tips
Label:
Original address: http://www.cnblogs.com/lantianhf/p/4744246.html


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.