打印一个ADOStoredProc的数据集
unit common_report;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, QuickRpt,adodb, QRCtrls,QRExport,Math,QRPrntr,
printers,TSDBGrid;
const
c_edt_str_width = 80;
// ´®±à¼­-¿í¶È
c_edt_str_height = 20;
// ´®±à¼­-¸ß¶È
c_edt_dat_width = 40;
// Êý¾Ý±à¼­-¿í¶È
c_edt_dat_height = 20;
// Êý¾Ý±à¼­-¸ß¶È
c_chk_width = 45;
// ¼ì²é¿ò-¿í¶È
c_chk_height = 17;
// ¼ì²é¿ò-¸ß¶È
c_cmb_width = 32;
// ×éºÏ¿ò-¿í¶È
c_cmb_height = 20;
// ×éºÏ¿ò-¸ß¶È
c_char_height = 12;
// ±êÇ©-¸ßϯ
c_width_per_char = 6;
// ±êÇ©-ÿ¸ö×Ö·û¿í¶È
c_grp_hdr = 8;
// ×éºÏ¿òµÄÍ·¸ß
c_margin = 4;
// ÔªËØÄÚÁоàºÍµ¥ÔªÄÚÐоà
c_ele_gap = 8;
// ÔªËؼäÁоà
c_unit_gap = 8;
// µ¥Ôª¼äÐоà
c_column_gap = 24;
// À¸¼ä¾à
c_band_width = 60;
// ±¨±íÏî-¿í¶È
c_band_height = 20;
// ±¨±íÏî-¸ß¶È
c_band_margin = 5;
// ±¨±íÄÚÏßÓëÊý¾ÝµÄ¾àÀë
c_page_hor_margin = 10;
// Ò³±ß¾à-ºáÏò
c_page_vert_margin = 10;
// Ò³±ß¾à-×ÝÏò
c_page_width = 210;
// Ò³-¿í¶È
c_page_height = 297;
// Ò³-¸ß¶È
c_pixel_per_mm = 23;
// ÿºÁÃ×ÏóËØÊý
c_segbar_width = 1;
// ·Ö¸ôÏß´Öϸ
c_report_title = 'none';
// ±¨±í±êÌâ
c_file_id = 'pjYan report';
// Îļþ±êÖ¾
c_file_name = 'report0';
// ÎļþÃû
c_file_ext = '.ypj';
// Îļþºó׺Ãû
type
Tcommon_rep = class(TForm)
c_rep: TQuickRep;
procedure FormCreate(Sender: TObject);
private
c_band:Tqrband;
c_shape:Tqrshape;
c_label:Tqrlabel;
c_dbtext:Tqrdbtext;
m_preview:boolean;
c_sys:Tqrsysdata;
pageset:boolean;
{ Private declarations }
public
procedure buildrepsp(adosp:TADOStoredProc;headtitle:string;reptitle:string);
{ Public declarations }
end;
var
common_rep: Tcommon_rep;
implementation
{$R *.dfm}
procedure Tcommon_rep.buildrepsp(adosp:TADOStoredProc;headtitle:string;reptitle:string);
var
I,j: Integer;
m:integer;
begin
m_preview:=false;
adosp.close;
if reptitle<>'' then
begin
c_band:=Tqrband.Create(self);
c_band.Parent:=c_rep;
c_band.BandType:=rbpageheader;
c_band.Height:=60;
c_label:=Tqrlabel.Create(self);
c_label.Parent:=c_band;
C_label.Font.Size:=24;
c_label.font.Name:='&Euml;&Icirc;&Igrave;&aring;';
c_label.Font.Style:=[fsbold];
c_label.Caption:=reptitle;
c_label.Left:=(c_band.Width-c_label.Width) div 2;
c_label.Top:=(c_band.Height-c_label.Height) div 2;
end;
c_rep.DataSet:=adosp;
if headtitle<>'' then
begin
//&acute;&acute;&frac12;¨±ê&Igrave;&acirc;&Iuml;&Ocirc;&Ecirc;&frac34;&Ccedil;&oslash;
c_band:=Tqrband.Create(self);
c_band.Parent:=c_rep;
c_band.BandType:=rbcolumnheader;
c_band.Height:=30;
c_band.Frame.DrawTop:=true;
c_band.Frame.DrawBottom:=true;
c_band.Frame.DrawLeft:=true;
c_band.Frame.DrawRight:=true;
j:=0;
m:=0;
for I := 0 to length(headtitle)do
// Iterate
begin
if copy(headtitle,i,1)='/' then
begin
c_label:=Tqrlabel.Create(self);
c_label.AutoSize:=false;
c_label.Parent:=c_band;
c_label.Caption:=copy(headtitle,m+1,i-1-m);
c_label.Left:=5+j*60;
c_label.Width:=60;
//c_label.Height:=(c_band.Height-c_label.Height) div 2;
c_label.Top:=(c_band.Height-c_label.Height) div 2;
c_shape:=Tqrshape.Create(self);
c_shape.Parent:=c_band;
c_shape.Width:=1;
c_shape.Height:=c_band.Height;
c_shape.Left:=60*(j+1)+1;
m:=i;
j:=j+1;
//showmessage(c_label.Caption);
end;
end;
// for
end;
adosp.Open;
if adosp.RecordCount>0 then
begin
//&acute;&acute;&frac12;¨&Ecirc;&yacute;&frac34;&Yacute;&Iuml;&Ocirc;&Ecirc;&frac34;&acute;&oslash;&Ccedil;&oslash;
c_band:=Tqrband.Create(self);
c_band.Parent:=c_rep;
c_band.BandType:=rbdetail;
c_band.Height:=18;
//c_band.Frame.DrawTop:=true;
//c_band.Frame.DrawBottom:=true;
c_band.Frame.DrawLeft:=true;
c_band.Frame.DrawRight:=true;
c_shape:=Tqrshape.Create(self);
c_shape.Parent:=c_band;
c_shape.Width:=c_band.Width;
c_shape.Height:=1;
c_shape.Left:=0;
c_shape.Top:=-1;
c_shape:=Tqrshape.Create(self);
c_shape.Parent:=c_band;
c_shape.Width:=c_band.Width;
c_shape.Height:=1;
c_shape.Left:=0;
c_shape.Top:=c_band.Height;
for I := 0 to adosp.FieldCount-1do
// Iterate
begin
c_dbtext:=Tqrdbtext.Create(self);
c_dbtext.AutoSize:=false;
c_dbtext.font.Size:=8;
c_dbtext.font.Name:='&Euml;&Icirc;&Igrave;&aring;';
c_dbtext.Parent:=c_band;
c_dbtext.DataSet:=adosp;
c_dbtext.DataField:=adosp.Fields.FieldName;
c_dbtext.Left:=5+i*60;
c_dbtext.Width:=60;
c_dbtext.top:=(c_band.Height-c_dbtext.Height) div 2;
c_shape:=Tqrshape.Create(self);
c_shape.Parent:=c_band;
c_shape.Width:=1;
c_shape.Height:=c_band.Height;
c_shape.Left:=60*(i+1)+1;
end;
// for
adosp.Close;
//&acute;&acute;&frac12;¨&Ograve;&sup3;&Icirc;&sup2;&Iuml;&Ocirc;&Ecirc;&frac34;&Ograve;&sup3;&Ecirc;&yacute;
c_band:=Tqrband.Create(self);
c_band.Parent:=c_rep;
c_band.BandType:=rbpagefooter;
c_band.Height:=20;
//c_band.Frame.DrawTop:=true;
//c_band.Frame.DrawBottom:=true;
//c_band.Frame.DrawLeft:=true;
//c_band.Frame.DrawRight:=true;
c_sys:=Tqrsysdata.Create(self);
c_sys.Parent:=c_band;
c_sys.Data:=qrsPageNumber;
c_sys.Height:=20;
c_sys.Width:=40;
c_sys.Left:=(c_band.Width-c_sys.Width) ;
c_sys.Top:=(c_band.Height-c_sys.Height) div 2;
c_sys:=Tqrsysdata.Create(self);
c_sys.Parent:=c_band;
c_sys.Data:=qrsdate;
c_sys.Height:=20;
c_sys.Width:=40;
c_sys.Left:=0;
c_sys.Top:=(c_band.Height-c_sys.Height) div 2;
adosp.Open;
c_rep.PreviewModal;
m_preview:=false;
adosp.Close;
end
else
begin
adosp.Close;
end;
end;
end.