Example of a qreport: multi-row display in Chinese, expansion of table lines when multiple rows are displayed, manual paging after expansion, and text reverse report (tried)

Source: Internet
Author: User

Unit unit1;

Interface

Uses
Windows, messages, sysutils, variants, classes, graphics, controls, forms,
Dialogs, quickrpt, qrctrls, extctrls, DB, ADODB, stdctrls;

Type
Tform1 = Class (tform)
Adotable1: tadotable;
Quickrep1: tquickrep;
Detailband1: tqrband;
Mecutword: tmemo;
Qrdbtext2: tqrdbtext;
Qrshape1: tqrshape;
Qrdbtext1: tqrdbtext;
Label1: tlabel;
Qrshape2: tqrshape;
Qrlabel1: tqrlabel;
Procedure qrdbtext1print (Sender: tobject; VaR value: string );
Procedure formcreate (Sender: tobject );
Procedure detailband1afterprint (Sender: tqrcustomband;
Bandprinted: Boolean );
Procedure quickrep1beforeprint (Sender: tcustomquickrep;
VaR printreport: Boolean );
Procedure detailband1beforeprint (Sender: tqrcustomband;
VaR printband: Boolean );
Private
{Private Declarations}
Public
{Public declarations}
Hhh: array of extended; // used to record the extended height of each record
End;
Const
Maxlen = 21;

VaR
Form1: tform1;
Rows: integer;

Implementation

{$ R *. DFM}

(* Detailband1afterprint, quickrep1beforeprint, detailband1beforeprint
Qrdbtext is used to expand down when multiple rows are displayed. By default, qrshape does not expand down,
The above three processes are used to solve this problem.
In addition, rows: integer;
Hhh: array of extended;
Setlength (hhh, 1000); // 1000 indicates the total number of records. Here, 1000 is an approximate representation.
// If possible, it should be accurately expressed to avoid space waste.
Quickrep1.prepare;

*)

Procedure tform1.qrdbtext1print (Sender: tobject; VaR value: string );
VaR
I: integer;
Text: tqrdbtext;
Begin
// Solve the problem of multi-line display in Chinese.
// Dbtext. autosize: = false;
// Dbtext. autostretch: = true;
// Dbtext. Wrap: = true;
Text: = sender as tqrdbtext;
Mecutword. Font. Assign (text. font); // specifies the font.
Mecutword. Width: = text. width; // specify the degree of parallelism.
Mecutword. lines. Clear; // clear the last thing
Mecutword. lines. Text: = value; // import value assign
Value: = mecutword. lines. Strings [0];
For I: = 1 to mecutword. lines. Count-1 do
Begin
Value: = value + #13 + mecutword. lines. Strings [I]; // extracts the data row by row and inserts it back.
End;

End;
Procedure tform1.formcreate (Sender: tobject );
Begin
Set length (hhh, 1000 );
Quickrep1.prepare;
Quickrep1.previewmodal;
End;

Procedure tform1.detailband1afterprint (Sender: tqrcustomband;
Bandprinted: Boolean );
Begin
Hhh [rows]: = quickrep1.bands. detailband. expanded;
Rows: = rows + 1;
End;

Procedure tform1.quickrep1beforeprint (Sender: tcustomquickrep;
VaR printreport: Boolean );
VaR
I: integer;
Begin
Rows: = 1;
For I: = 0 to quickrep1.bands. detailband. controlcount-1 do // iterate
Begin
If quickrep1.bands. detailband. controls [I] Is tqrshape then
(Quickrep1.bands. detailband. controls [I] As tqrshape). Height: =
Quickrep1.bands. detailband. height;
End; //
End;

Procedure tform1.detailband1beforeprint (Sender: tqrcustomband;
VaR printband: Boolean );
VaR
I: integer;
Begin

For I: = 0 to quickrep1.bands. detailband. controlcount-1 do // iterate
Begin
If quickrep1.bands. detailband. controls [I] Is tqrshape then
Begin
(Quickrep1.bands. detailband. controls [I] As tqrshape). Top: = 1;
(Quickrep1.bands. detailband. controls [I] As tqrshape). Size. Height: =
Quickrep1.bands. detailband. Size. height + hhh [rows];
End;
End;
End;

End.

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.