QuickReport universal print program

zhaozj2021-02-16  56

The program is often printed, using the Delphi programming to use QuickReport to make report printing, Rave is in Delphi7, I use QuickReport to make an universal print program, due to time is urgent, there is no time optimization and beautification, Welcome netizens to modify.

His basic idea is: Dynamic Take the column in DataSet, dynamic generating reports, the program is as follows:

Unit UNIT_QREPORT_LXR;

Interface

Uses Windows, Sysutils, Messages, Classes, Graphics, Controls, Stdctrls, ExtCtrls, Forms, Quickrpt, Qrctrls, DB, AdoDB, Dialogs

Type tqreport_lxr = class (tquickrep) detailband1: tqrband; titleband1: tqrband; bb_title: tqrlabel; columnheaderband1: tqrband; private

Public Function BB_PREPARE (ObjadoQuery: TDataSet; Havefirstcol: Boolean): Boolean; End;

VAR Qreport_LXR: TQREPORT_LXR;

IMPLEMentation

{$ R * .dfm} function tqreport_lxr.bb_prepare (ObjadoQuery: tdatan): boolean; file: // Havefirstcol: boolean; is printed in the first column in DataSet, true printing, false does not print Var La: tqrlabel TE: TQRDBText; Row_LA: Integer; ROW_TE: Integer; Re_Width: Integer; Left_bj: Integer; I: Integer; J: Integer; M: Integer; Hafn: Integer; Begin

IF (ObjadoQuery.fields.count <= 0) THEN Begin Messagedlg ('Please do query first, then print the report!', mtinformation, [mbyes], 0); result: = false; exit; end; self.dataset: = objadoQuery; if objadoquery.Recordcount <> 0 THEN BEGIN ROW_LA: = 0; Row_Te: = 0; Left_bj: = 0; J: = 0; Re_Width: = Detailband1.Width; M: = RE_WIDTH DIV 100;

File: // Note: Whether to abandon the first column IF HAVEFIRSTCOL THEN HAFN: = 0 else hafn: = 1; for i: = hafn to objadoQuery.fieldcount-1 Do Begin if j = m1n Begin Left_bj: = 0 ; row_la: = row_la 1; row_te: = row_te 1; j: = 0; ColumnHeaderBand1.Height: = ColumnHeaderBand1.Height 27; DetailBand1.Height: = DetailBand1.Height 27; end; la: = TQRLabel.Create (self); la.caption: = objadoQuery.fields [i] .fieldname; la.Width: = 100; la.Height: = 17; la.left: = left_bj; la.top:=30 (la .height 10) * Row_La; la.parent: = columnheaderband1;

TE: = tqrdbtext.create (self); te.dataset: = objadoQuery; te.datafield: = objadoQuery.fields [i] .fieldname; te.width: = 100; te.height: = 17; te.left: = Left_bj; te.top:=30 (TE.HEIGHT 10)*row_te; te.parent: = DetailBand1; TE.AUTOSTRETCH: = TRUE

LEFT_BJ: = (J 1) * 105; J: = J 1; END; END; RESULT: = true; end;

The calling program is as follows:

转载请注明原文地址:https://www.9cbs.com/read-16253.html

New Post(0)