RAVE report in Delphi 7 (5)
- Reports for database connection
Take the Access database as an example, first create a database, create a table included the fields: {[Name], [SEX], [AGE], [PROVINCE]}, or not too little. First, we don't consider the call of the Delphi program, open RAVE to create a new Report; 1. [File] ànew data object à Select Use connection string. Select [Microsoft Jet 4.0 Ole DB Provider], select the location of the saved database and the test connection is successful. After [OK], the Data View Dictionary of the report design navigation area increased Database1; 2. [File] ànew Data Object Driver Data View Select Database1 [FINISH] to pop up Query Advenced Designr, drag and drop the data sheet of Query Advenced DesignR's Tables column to layout à [ok] à [ok] à See the Data View Dictionary area of the report design navigation area DRIVEDATAVIEW1, you can see the data field after extension; 3. Select [Tools] àreport WizardsàSingle Table Select DriveDataView1, select Database Field Report Title to "Personal Situation Report". Ok, you can see the report in Page. 4. Press [F9] or shortcut [Execute Report], you can see reports connected to the database, and the RAVE report is automatically paging according to the amount of data. Change the format as needed, preview until you want the report format you want. At this time, it is very simple to complete a report, of course, some people may see that the title of the report is shown in the first page of the report, there is no display in other pages. How to make the title display at each page? Select TitleBand, set the BandStyle to check the New page in Print Occurrence, which will find that every page generated in the preview you will have a title. Of course, when our report is called by program, then we can design a report to connect the database in Delphi. 1. New projects, place the following components on the form: RvProject, Rvsystem, RVDataSetConnection, Adoconnection, ADOTABLE, DATASOURCE, Button, DBGRID. Setting the appropriate database connection You can see that the data is displayed in the DBGRID, and the specific settings are not explained here, please refer to the appropriate database book. RVSystem1 Engine is RVSystem1, RvProjectFile selects a * .rav file saved. The DataSet property of RVDataSetConnection1 is set to: adotable1. 2. Open the RAVE designer to open the * .rav file. 3. [file] ànew Data Objectàdirect Data Viewà Select RVDataSetConnection1, [FINISH] See the Data View Dictionary of the report design Navigation area Add DataView1, you can see the data field after the extension; 4. Use the previous step 3, the same method, Report visual design.
At the time of visual design, pay attention to the components of the generated simple database code, pay attention to the property settings of TitleBand, DataBand, and Band. Of course, we can also automatically generate itself without Report Wizards, you can do your report as needed. The step is: 1) Add the component page of the region component to describe the scope of the report. 2) Add BAND, BAND, DATABAND components, set the appropriate BandStyle and DataView properties. 3) Add, DataText selects its DataView attribute and DataFile property. 4) Preview, if you do not display properly, pay attention to view the settings of the property, especially the DataView property, while comparing the reports automatically generated by Report Wizards. 5. Add the following code: Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT); begin rvproject1.open; rvproject1.executereport ('report1'); rvproject1.close; end; 6. After running, click the [OK] button, display report Set the form, you can see the form you want to get after you are determined. Some questions about and database connection reports: 1) The above example is the report directly from the database, if the report to output is based on the user's condition, what should I do? If you want to output a corresponding report according to the user's condition, use the Query component, of course, it is also the same as the operation of the stored procedure. Select the appropriate database access component to connect the RVDataSetConnection's DataSet property to the database access component. 2) I am Chinese in the field in the database table, connect the database in RAVE, DataView can't display my field, and prompt "DataView1 already exists!", What should I do? " Such a problem, mainly, the Name property of DataView1 does not support the Chinese name, and cannot be named according to the data segment name, you change DataView1 to the corresponding English name, change the field of FieldName as the response field, refresh the DataView, there will be prompts, Also change the Name and FieldName properties until you want the fields to change. 3) When the default report is vertical, how can you set the page to horizontally? For information on the page, please pay attention to the properties of RVSystem. RvSystem1.SystemPrinter.Orientation: = poLandScape; // page to landscape the RvSystem1.SystemPreview.FormState: = wsMaximized; // preview maximize a form RvSystem1.SystemPreview.MarginPercent: = 3; // According to the report page preview of the form side distance. Of course, there are still a lot of settings TitleSetup, TitleStatus, and TitlePreView properties can be changed to you want to set your report. Of course, our most basic is to change to Chinese. I will introduce it to the Chinese. I will introduce it to the Chinese. (PS: Please indicate the author - the fish (CYQ) on the highway)