RM (Report Machine) is a powerful Delphi report control package. Use it to create very complex reports. The simplest usage is explained below:
Put two database controls on the Form: ADOConnection and ADOQuery to set up the ConnectionString of ADOConnection. LoginPRompt=False. ADOQuery's Connection points to ADOConnection. ADOQuery's SQL sets up data query statements.
Put two RM report controls on the Form: RMDBDataSet and RMReport. The DataSet of RMDBDataSet points to ADOQuery. The DataSet of RMReport points to the RMDBDataSet.
(If you want the final generated application to have report design capabilities, you also need to put the RMDesigner control and do not set any attributes)
Double-click the RMReport control to start designing the report template.
For reports that are generally compared with rules, you only need to add four Band objects to the template, namely: 1), page header: usually used to display report name, time, etc. 2), main item header: usually used to display columns name. 3) Main item data: used to display data. 4) Page footnote: used to display page number, date, etc.
The designed template can be saved in DFM or in an independent template file with the extension RMF and is called in at runtime. Here are a few code snippets:
procedure TBrowseForm.Button5Click(Sender: TObject);varRMReport:TRMReport;beginif ADOQuery1.IsEmpty thenExit;tryRMReport := TRMReport.Create(Self);RMReport.LoadFromFile('Match.rmf');RMReport.PrepareReport;RMReport.ShowReport; finallyRMReport .Free;end;end;
procedure TForm1.Button1Click(Sender: TObject); beginRMReport1.ShowReport; end;
// Design report template procedure TForm1.Button2Click(Sender: TObject); beginRMReport1.LoadFromFile('TTT.rmf');RMReport1.DesignReport; end;
For most rules reporting, the above knowledge is sufficient. But this is just the simplest way to use RM, and it is far from reflecting the power of RM functions.
RM has two attractive features that I need most at the moment:
1) The data can come from the database or from anywhere else, such as in files, in memory, etc. 2) It is not necessary to pre-made templates. You can generate templates through code at the run time, which is very useful for situations where the number of fields in the data is uncertain.
Although RM is powerful, it doesn't feel complicated to use. It is the best of the few report controls I have seen.
1. What are your good solutions for a report that requires two sides of a piece of paper? You can choose to type odd or even pages when printing. 2. How can I print a fixed number of lines in one page? How to print a blank grid when the last page is not recorded enough? Fixed number of lines: Set LinesPerPage blank grid: Set AutoAppendBlank=True3. How to block double-click the report to enter the design report Interface? RMReport1.ModifyPrepared := False4. How to add a table total to the report??? It can be placed in the title bar. Select TotalCalc=True in the report summary box twice in the page settings 5. I want to use code to pass parameters to the report How to do a TRMMemoView? RMReport1.FindObject('Memo1').Memo.Text := 'ddddd' or RMVariables['a1'] := 'ddddd'; //This way you can use the variable 'a1' in the report. 6. How can we not print duplicate content? Suppres=True7. How to make double-clicking when printing preview cannot enter the report editor! Set RMReport.ModifyPreview=False8. How to control whether the border of MEMO is displayed in delphi in the report program: memo1.LeftFrame.Visible := Falsememo1.TopFrame.Visible := False;memo1.RightFrame.Visible := False;memo1.BottomFrame .Visible := False in the report's script memo1.FrameTyp := 15; //Try this parameter a few times to know how to set FrameTyp := 0; //Don't display 9. How to change the name of the page and control it to display But it is OK to not print. In the OnBeforePrint of Page1, beginPage1.Visible := True;Page1.Visible := False; //No end is displayed; 10.Report Machine, how to force a table for each 3 rows to set the main item data column: LinesPerPage =3If there is a way for three people to one line: Set the Columns of the main item data column=3 Print in grouping, grouping conditions: NowLine > 3 OnBeforePrint:beginNowLine := 1;end; OnBeforePrint:beginNowLine in the grouping header := NowLine + 1;end;11. Can only display the grouping statistics value without displaying the grouping data? Yes, set the main item data column: Visible=False statistics box: CalcNoVisible=True12. Can only fold a single record that exceeds the length? Yes, set the text box: Stretched=True; Wordwrap=True Set the column where the text box is located: Stretched=True; Breaked=True13. How to implement print preview RMReport1.LoadFromFile('c:1.rmf'); //Read Enter the report RMReport1.ShowReport; //Preview RMReport1.PrintReport; //Print RMReport1.DesignReport; //Design14. How to control in the program: 1. Print vertically or horizontally. 2. Whether the group headers change pages in each group. 1.RMReport1.Pages[0].ChangePaper()2.RMReport1.Pages[0].FindObject(group header column name).Prop['NewPage'] := False;15. What is the method of direct printing? RMReport1.ShowPrintDialog := False;RMReport1.PrintReport;16. After the page margin is changed, all controls should change their position accordingly. You need not select the zoom to printable area in the page settings or RMReport1.Pages[0].pgMargins := ; //Try this 17. How to import a rtf file as TRMFormReport PageHeadervarTempStream: TMemoryStream; beginTempStream := 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 TRMDesigner's TemplateDir19. I want to dynamically set up the virtual dataset! (RMReport1.FindObject('Band1') as TRMBandView).DataSet :='RMDBDataSet1';20. In the program RMVariables['aaa'] := form1.Caption; in the report you can use the variable 'aaa'21. Left Distance: CurReport.Pages[0].pgMargins.Left := Round(RMConvertToPixels(mm*10, rmsuMM)) 22.RMVariables['Brand'] :=True;RMVariables['Product Name'] :='Computer'; The code in Page1's OnBeforPrint event is as follows: If brand ThenMessageBox (product name); 23. How to deal with only 10 records per page? Main item data column LinePerPage=1024. How to implement statistics of main item data? ? ? It is best to use the column footnote column, put a statistics box on it, and then set CalcType 25. When dynamically generating reports, how to set the page margin of RM? TRMPage.pgMargins := Rect(30, 30, 40, 40); 26. How to open multiple report files at once in a preview or printing window when the program is running, in a preview or printing window, use TRMCompositeReport, RMCompositeReport1.Reports.Clear; RMCompositeReport1.Reports.Add(RMReport1); RMCompositeReport1.Reports.Add(RMReport2); RMCompositeReport1 .ShowReport;27.rm How to set up Page1 does not have a BackGroundPic attribute? This is specially designed for set up 28. Can GridView1 implement a3=a1+a2 like Microsoft Excel? Yes, a3 content [memo1.CalcValue + memo2.CalcValue]29. Use the total number of pages, place CalcMemoView in the header, group header, and column header of the report needs to be selected twice, which has no effect on printing, and only prints once.30. How to print brackets such as: [2002] beginmemo := '[2002]';end; or define '[',']' as a variable: RMVariables['a1'] := '[';
RMVariables['a2'
report machine development user manual - create report 2010-02-10 13:08
Create a report:
Creating a report consists of the following steps:
1. Select data: Select the data source used in the report
2. Design report templates: Use the area (called Band) to distribute different parts of the report to determine the report style.
3. Processing: Use the built-in script language of the report or process the data, report templates, etc. used in the report in delphi.
4. Generate report: Generate the final report based on the report template + data source.
Select a data source:
The data required for most reports comes from the database. TTable and TQuery components can serve as data sources for reports. In general, it can use any subclass inherited from the TDataSet component. The TDataSet used in each report must have a corresponding TRMDBDataSet.
In addition to TDataSet, ReportMachine pages can use any data source (arrays, files, character grids, etc.). In this case, the program must control the access of non-database sources by itself. You can use TRMUserDataSet to easily transfer data to reports.
Design report template:
The report template itself describes how to see the correct report. Each report template consists of multiple regions, which ReportMachine calls Band. There are two types of Bands: fixed area Bands (such as report titles, page headers, page footnotes, etc.) and Bands used to display all records in the dataset (such as the main item data column). The data band needs to be connected to the data source, and the content is a record in the data source.
ReportMachine provides a visual environment for report development (report designer, which can also be provided to your End User to facilitate your End User to modify the report templates by yourself) for creating reports. Report Designer is powerful, simple and easy to use. The report designer interface is made of a floating toolbar, which can freely change their position. Use the Objects Inspector to control the properties of objects, similar to the one in the Delphi IDE.
deal with:
When generating a report, you need to process the input data (such as formatting), and the report template needs to be modified (such as a text box in the report template needs to change the font).
Implementing this processing allows you to write code in event processing of TRMReport in Delphi. This method is not universal because it does not allow the creation of reports outside Delphi without recompiling. This is why the built-in scripting language in ReportMachinet, the built-in scripting language of ReportMachine is very similar to Object Pascal, and is powerful. Write event processing code in this scripting language, which allows you to create complex processing without writing code in Delphi. In conjunction with the report designer, you do not need to modify a report and recompile the project. It can separate reports from your projects.
Report script example:
unit Report;
interface
procedure Memo1OnBeforePrint(Sender: TObject); implementation
procedure Memo1OnBeforePrint(Sender: TObject); beginMemo1.Text := 'test';end;
procedure Main; begin
end;
end.
Generate a report:
Generating a report is a process in which ReportMachine processes the data source according to the report template to generate the final report and can preview it after clicking the "Preview" button. Reports prepared in ReportMachine are a collection of objects that describe the content contained in each page after the report is processed. This allows you to modify the generated report page by calling the desired page in the designer. In addition, the reaction of the mouse clicking on the object in the preview window can also be described. This will make it easier for you to organize your work (clicking on a report object can produce a more detailed new report).
The preview window of ReportMachine is similar to Microsoft Word: multiple pages can be seen in one window and can be dragged with a mouse. If necessary, you can double-click to bring up the editor to modify the current page.