First, simply understand each control function
The following is the simplest use of each control, and other functions are described in specific implementation.
TquickRep: With coordinates, as other report controls (such as tqrband), its Band property can automatically add various types of TQRBAND. TQRLabel: Print static text (ie, change according to database values), like TLABEL The content of CAPTION is printed. TqrdbText: Print the database field value, one value is one line. The role is like TDBText. When the table1, DataField gives Table1 and Company, the contents of the table of tables pointed to the table1 are printed. TQRSYSDATA: Print system information such as time, page number, report head, etc. TQRMEMO: Very like Tqrlabel, just it can print multi-line, and print static data. TQRRICHTEXT: Prints the RichText format, which can connect to the Richedit control on a Form and print it, but must be 32-bit versions. TQRSHAPE: Printing boxes, circles and vertical, horizontal lines.
TQRIMAGE: Print static pictures, including (BMP, WMF, ICON).
TQRDBIMAGE: Receive images from the database.
TQRBAND: What should be displayed for different locations of the report, which can be put on the above (see 2).
TQRGOUPS: Groups can be operated without levels. When you connect several DataSets to the report, you can operate the DataSet via Groups. Second, the control of the report is placed
The title (the tophead) title (TITLE) The title of all columns recorded, a field (the last page) (Summary) appears Page Footer on all pages
These are positioned according to the different BANDs (not controls, one type, which can put other controls above). There are six kinds of bands.
Third, a simple example This example makes some field names that print a table and reports of the field data content.
Create a new Project
Playing a TTable to Form, DatabaseName is set to bcdemos, TableName points to the Customer table, and Active is set to true.
Playing a TQUickRep control On the Form, the DataSet property is Table1. (Ie, displayed within the table pointed to by Table1).
Expand TquickRep's BANDS property, set HasDetail to True, then automatically add a Detail Band (a TQRBAND control, you can also put a TQRBAND control directly, the BandType property is set to Detail).
Put a TQRDBText control over the detail band, set the DataSet point to Table1, DataField points to Company. The fourth step is to set what type of data is displayed on what location of the report, and TQRDBText is implemented.
Choose the TQUickRep control, press Right-click, select "Preview" Preview, you should see all field values of the table Customer field Company.
To this simple example is OK, the program implements the preview and the print function that uses TQRUickReprep that only needs to add a button in Form, its OnClick event is: QuickRep1-> preview ();
Fourth, a report using TQRGOUPS and TQREXPR controls The statement first lists the state name, then lists all the companies and the total number of companies in the state, one state is listed in the back, and the new state name is listed. All companies under the new state, the company that is not filled with the state is listed under Unknown State. Create a new project.
Playing a TQuery on tquickrep, its SQL property is: Select * from customer order by state, company; (ie, according to the state, company sorting), DatabaseName is bcdmome, Active is True.
Put a TquickRep control on Form1, Dataset is TQuery1.
Put a TQRGroups control on tquickrep, then the default is Group header. (This header will be printed when the Group is interrupted or higher from the group interrupt, and this header will be printed. If there is an expression, according to the value of the expression.) Next, add a group footer Band, add a TQRBAND control On the report, connect TQRGroups's FooterBand attribute to this QRBAND. At this time, the new TQRBAN has become Group Footer. (One important feature of TQRGroup is an expression, and when the value of the expression will be interrupted, such as expressions In order to list the city name in the province, the current listing of Guangdong Province, when it belongs to the province, the expression value changes, then the Group is interrupted, then display the city name of other provinces.) TQRGroups Expression property is set to query1 .State (interrupted according to different states).
Put a TQRBAND control on the report, BandType is RBDetail.
Put a TQREXPR control over the Group header, its Expression property is: if (State <> ', State,' Unknown State '), that is, if the company's state is not filling, you will be classified into Unknown State, otherwise you will be classified.
Put three TQRDBText on detail, their DataSet points to Query1, DataField points to Company, Contact, Phone, respectively.
In the GROUP FOOTER, Expression is the total of the company after the company's company is completed after each state company, how many companies are displayed after each state company.
Press Right to select Preview, you should see the total number of state names and their company and company companies. V. QuickReport Conditional Print Conditions directly in TquickReport's Onfilter event, there is a VAR-based PrintRecord Bablin type variable in the ignition of the ONFILTER event, set this variation to true (preset value), The record will be printed; in turn, set to false, this record is not printed.
procedure TForm1.QuickReport1Filter (var PrintRecord: Boolean); begin PrintRecord: = False; if YourTable.FieldByName ( 'WantedField') AsInteger <= 100 then Exit; if YourTable.FieldByName ( 'WantedField') AsInteger.> = 150 then Exit. PrintRecord: = true;