Report Machine (RM) reporting controls simple usage-delphi

Source: Internet
Author: User

RM is a powerful Delphi report control package. Use it to create very complex reports. The simplest usage is described below:

Put two database controls on a form: ADOConnection and Adoquery
Set the connectionstring of the ADOConnection. Loginprompt=false.
Adoquery's connection points to adoconnection.
Adoquery SQL sets up the data query statement.

Put two RM report controls on a form: Rmdbdataset and Rmreport.
The Rmdbdataset dataset points to adoquery.
The Rmreport dataset points to Rmdbdataset.

(If you want the resulting application to have report design capabilities, you'll need to put the Rmdesigner control on, and you don't need to set any properties)

Double-click the Rmreport control to begin designing the report template.

For a report of a general comparison rule, simply add four band objects to the template, namely:
1), page header: Typically used to display report name, time, etc.
2), item header: Usually used to display the column name.
3), item data: used to display data.
4), page footer: Used to display the page number, date and so on.

A well-designed template can be saved in DFM or saved to a standalone template file with the extension RMF and run Si cho in. Here are a few pieces of code:

Procedure Tbrowseform.button5click (Sender:tobject);
Var
Rmreport:trmreport;
Begin
If Adoquery1.isempty Then
Exit;
Try
Rmreport: = Trmreport.create (self);
Rmreport.loadfromfile (' MATCH.RMF ');
Rmreport.preparereport;
Rmreport.showreport;
Finally
Rmreport.free;
End
End

Procedure Tform1.button1click (Sender:tobject);
Begin
Rmreport1.showreport;
End

Designing a report template
Procedure Tform1.button2click (Sender:tobject);
Begin
Rmreport1.loadfromfile (' TTT.RMF ');
Rmreport1.designreport;
End

For most rule reports, the above knowledge is sufficient. But this is the simplest use of RM, far from the power of the RM function.

RM has two appealing features that I need most today:

1), data can be from the database, or from anywhere else, such as files, memory medium.
2), do not need to pre-make a good template, you can run at runtime through the code to generate a template, which is very useful for the variable number of fields in the data.

RM is powerful, but it's not very complex to use, it's the best of the few report controls I've ever seen.

1. What's the best way to make a report on both sides of a sheet of paper?
You can choose to play odd pages or even pages when printing.
2. How to print a fixed number of bars in a page, and the last page of the record is not enough when the blank lattice out AH.
Fixed number of bars: set linesPerPage
Blank lattice: Set autoappendblank=true
3. How to block double-click the report to enter the design report interface?
rmreport1.modifyprepared: = False
4. How to increase the table totals in the report???
Can be placed in the title bar, page Setup Select "two Times report"
Totalcalc=true of the Summary box
5. I want to use code to pass parameters to one of the Trmmemoview in the report.
Rmreport1.findobject (' Memo1 '). Memo.text: = ' ddddd '
Or
rmvariables[' a1 ': = ' ddddd '; This makes it possible to use the variable ' A1 ' in the report.
6. How can I not print duplicate content?
Suppres=true
7. How to make print preview when double-clicking cannot enter the report editor!
Set Rmreport.modifypreview=false
8. How to control whether the border of memo is displayed in the report program
In Delphi:
Memo1. Leftframe.visible: = False
Memo1. Topframe.visible: = False;
Memo1. Rightframe.visible: = False;
Memo1. Bottomframe.visible: = False
In a script in a report
Memo1. Frametyp: = 15; This parameter can be tried a few times to know how to set up
Frametyp: = 0; does not display
9. How to change the name of the page and control it to display but not print
Yes, in the onbeforeprint of Page1.
Begin
Page1.visible: = True;
Page1.visible: = False; does not display
End
10.Report machine, how to force a table per 3 rows
Set Item data bar: linesperpage=3
If three people have a way: Set the columns=3 of the item data bar
Printing in groups, grouping conditions: nowline > 3
Onbeforeprint in the group header:
Begin
Nowline: = 1;
End
In the onbeforeprint of the item data:
Begin
Nowline: = Nowline + 1;
End
11. Can I display only grouped statistics without displaying grouped data?
Yes, set item data bar: Visible=false
Statistics Box: Calcnovisible=true
12. Can I fold only a single record that is longer than the length?
Yes, set text box: Stretched=true; Wordwrap=true
Set the column where the text box is located: stretched=true; Breaked=true
13. How to implement the print preview problem
Rmreport1.loadfromfile (' C:1.RMF '); Read-in Report
Rmreport1.showreport; Preview
Rmreport1.printreport; Print
Rmreport1.designreport; Design
14. How to control in the program: 1, Portrait printing or horizontal printing. 2. group header whether each group of pages is changed.
1.rmreport1.pages[0]. Changepaper ()
2.rmreport1.pages[0]. Findobject (group header column name). prop[' NewPage ']: = False;
15. What is the direct printing method?
Rmreport1.showprintdialog: = False;
Rmreport1.printreport;
16. After the margin changes, all controls should change position accordingly.
You need to uncheck the "Zoom to printable area" page in the page Setup to center or
Rmreport1.pages[0].pgmargins: =; Give it a try.
17. How to import an RTF file as a trmformreport PageHeader
Var
Tempstream:tmemorystream;
Begin
Tempstream: = tmemorystream.create;
RichEdit1.Lines.SaveToStream (Tempstream);
Tempstream.position: = 0;
RMFormReport1.PageHeader.Caption.LoadFromStream (Tempstream);
Tempstream.free;
End
18. How to determine the report template directory?
Set the Templatedir of Trmdesigner
19. I would like to set up a "virtual data set" How to set!
(Rmreport1.findobject (' Band1 ') as Trmbandview). DataSet: = ' RMDBDataSet1 ';
20. In the program
rmvariables[' aaa ']: = Form1. Caption;
The variable ' AAA ' can be used in the report
21. Left margin:
Curreport.pages[0].pgmargins.left: = Round (Rmconverttopixels (MM *, Rmsumm))
22.rmvariables[' brand ': =true;
rmvariables[' name ']: = ' computer ';
The code in the Page1 Onbeforprint event is as follows:
If Brand Then
MessageBox (name);
23. How to deal with only 10 records per page? Item Data Bar lineperpage=10
24. How to achieve the statistics of the master data ah???
It is best to use the column footnote bar, put the statistics box above, and then set Calctype can
25. How are the RM margins set when generating reports dynamically?
Trmpage.pgmargins: = Rect (30, 30, 40, 40);
26. How to open multiple report files at once in a preview or Print window when the program is running
With Trmcompositereport,
RMCompositeReport1.Reports.Clear;
RMCOMPOSITEREPORT1.REPORTS.ADD (RMREPORT1);
RMCOMPOSITEREPORT1.REPORTS.ADD (RMREPORT2);
Rmcompositereport1.showreport;
27.rm How to make a set dozen
Page1 not have a backgroundpic attribute, this is a special set to play
28.gridview1 can be like Microsoft Excel
Do you realize a3=a1+a2?
Yes, A3 content
[Memo1. Calcvalue + Memo2. Calcvalue]
29.
Use the total number of pages, put Calcmemoview in the header, group header, column header need to select "two Times report", the printing does not affect, only printed again.
30. How to print the brackets such as: [2002]
In the onbeforeprint of Memoview
Begin
Memo: = ' [2002] ';
End
or define ' [', '] ' as a variable:
rmvariables[' a1 ': = ' [';

rmvariables[' A2 '

Reports machine Development Manual-Create a report 2010-02-10 13:08

To create a report:

Creating a report consists of the following steps:

1. Select data: Select the data source used in the report

2, Design the report template: Use the area (called band) to distribute the report to different parts, determine the report style.

3, Processing: Using the report built-in scripting language or in Delphi in the report used in the data, report template, etc.

4. Generate the report: Generate the final report based on the report template + data source.

Select a data source:

Most reports require data from a database. Ttable and Tquery components can be used as data sources for reports. In general, it can use any subclass that inherits from the Tdataset component. The tdataset used in each report should have a corresponding trmdbdataset.

In addition to the Tdataset,reportmachine page you can use any data source (array, file, character grid, etc.). In this case, the program must control access to the non-database source itself. You can easily transfer the data to the report using Trmuserdataset.

To design a report template:

The report template itself is a description of how you can see the correct report. Each report template consists of multiple regions, reportmachine these areas as "Band". There are two types of band: fixed-area band (such as report title, page header, page footer, and so on) and band (such as the Master Data bar) that are used to display all records in the dataset. Data band need to be joined to a data source, and the content is a record in the data source.

A visual environment for report development is provided in Reportmachine (Report Designer, which can also be provided to your end user to make it easier for your end user to modify the report template yourself) for creating reports. Report Designer is powerful, simple and easy to use. The Report Designer's interface is made up of a floating toolbar that allows you to freely change their position, using the Object Viewer (Objects Inspector) to control the object's properties, similar to that in the Delphi IDE.

Processing:

When you generate a report, you need to do some processing of the input data (such as formatting), and the report template needs some modifications (such as a text box in the report template that needs to change the font).

Implementing this processing can write code in Trmreport event handling in Delphi, which is not generic because it does not allow reports to be created outside of Delphi without recompiling. That's why the built-in scripting language in Reportmachinet, Reportmachine's built-in scripting language is very similar to object Pascal, and powerful. Writing event-handling code in this scripting language allows you to create complex processes without having to write code in Delphi, with Report Designer, without having to modify a report to recompile the project. You can implement reports that are detached from your project.

Report Script Example:

Unit report;

Interface

Procedure Memo1onbeforeprint (Sender:tobject);
Implementation

Procedure Memo1onbeforeprint (Sender:tobject);
Begin
Memo1.text: = ' test ';
End

Procedure Main;
Begin

End

End.

To generate a report:

Generating a report is a process by which Reportmachine produces a final report based on the report template, processing the data source, and previewing it after clicking the Preview button. A report that is prepared in Reportmachine is a collection of objects that describe what the pages contain after the report is processed. This allows you to modify the generated report page by invoking the desired page in the designer. In addition, you can describe how the mouse clicks the object's response in the preview window. This will make it easier for you to organize your work (click on a report object to produce a more detailed new report).

The preview window in Reportmachine is similar to Microsoft Word: you can see multiple pages in a single window, and you can use the mouse to drag them, and then double-click to bring up the editor to modify the current page.

Report Machine (RM) reporting control simple usage-delphi

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.