用Delphi开发报表打印的ASP组件

页面导航:首页 > 软件编程 > Delphi > 用Delphi开发报表打印的ASP组件

用Delphi开发报表打印的ASP组件

来源: 作者: 时间:2016-01-21 09:33 【

ASP在对数据库操作方面提供了很好的内嵌对象。但是,其他方面的功能有所欠缺,如:报表打印。特别是国内的复杂的报表,用ASP很难实现。 不过,ASP

 

       ASP在对操作方面提供了很好的内嵌对象。但是,其他方面的功能有所欠缺,如:报表打印。特别是国内的复杂的报表,用ASP很难实现。

       不过,ASP支持插件,这就可以根据需要开发ASP插件,笔者用Delphi5.0开发了ASP打印。下面笔者将分步来开发一个通用的报表打印的ASP组件。

       第一步:新建一个Activex Library,命名为PrintT,然后再新建一个Active Server Object Class,命名为Print,即建立了一个名为Print的ASP组件,文件命名为Unit1.pas。

      第二步:打开Type Library,新建一个方法Print1,用于传递报表打印。

      第三步:新建一个DataModule,放入Adoconnection组件和AdoTable组件,文件名为Unit2.pas。

     第四步:新建一个TQuickRep,设计你要打印的报表,文件名为文件名为Unit23.pas。以下是个文件的详细代码:
{=============Unit1.pas===============}

unit Unit1;

interface

uses
  ComObj, ActiveX, AspTlb, PrintT_TLB, StdVcl;

type
  TPrint = class(TASPObject, IPrint)
  protected
    procedure OnEndPage; safecall;
    procedure OnStartPage(const AScriptingContext: IUnknown); safecall;
    procedure Print1; safecall;
  end;

implementation

uses ComServ,unit2,unit23;

procedure TPrint.OnEndPage;
begin
  inherited OnEndPage;
end;

procedure TPrint.OnStartPage(const AScriptingContext: IUnknown);
begin
  inherited OnStartPage(AScriptingContext);
end;

procedure TPrint.Print1;
begin
     IdearRpt.Print;
end;

initialization
  TAutoObjectFactory.Create(ComServer, TPrint, Class_Print,
    ciMultiInstance, tmApartment);
end.

{===============Unit2.pas===============}

unit Unit2;

interface

uses
  SysUtils, Windows, Messages, Classes, Graphics, Controls, Forms,
  Dialogs, DBTables, DB, ADODB;

type
  TCustomerData = class(TDataModule)
    ADOConnection1: TADOConnection;
    ADOTable1: TADOTable;
    DataSource1: TDataSource;
    ADOTable1NIANH: TStringField;
    ADOTable1XUH: TStringField;
    ADOTable1SHENQDW: TStringField;
    ADOTable1SHENQRQ: TDateTimeField;
    ADOTable1FARDB: TStringField;
    ADOTable1FARDH: TStringField;
    ADOTable1LIANXR: TStringField;
    ADOTable1LIANXRDH: TStringField;
    ADOTable1DANWZCDZ: TStringField;
    ADOTable1JIANSXZDM: TStringField;
    ADOTable1JIANSGM: TBCDField;
    ADOTable1ZHIGRS: TBCDField;
    ADOTable1YONGDFH: TBCDField;
    ADOTable1RIYSL: TBCDField;
    ADOTable1RIPSL: TBCDField;
    ADOTable1JIANZSJGD: TBCDField;
    ADOTable1RANQYL: TBCDField;
    ADOTable1YONGDYQ: TStringField;
    ADOTable1RELYL: TBCDField;
    ADOTable1JIANSXM: TStringField;
    ADOTable1PIZWH: TStringField;
    ADOTable1JIANSGM2: TBCDField;
    ADOTable1YONGDXZDM: TStringField;
    ADOTable1YONGDWZ: TStringField;
    ADOTable1DONGL: TStringField;
    ADOTable1XIL: TStringField;
    ADOTable1NANL: TStringField;
    ADOTable1BEIL: TStringField;
    ADOTable1CHANG: TBCDField;
    ADOTable1KUAN: TBCDField;
    ADOTable1ZONGMJ1: TBCDField;
    ADOTable1ZONGMJ2: TBCDField;
    ADOTable1YOUXRQ1: TDateTimeField;
    ADOTable1YOUXRQ2: TDateTimeField;
    ADOTable1BEIZ: TStringField;
    ADOTable1JINGB: TStringField;
    ADOTable1SHENH: TStringField;
    ADOTable1SHEND: TStringField;
    ADOTable1SHENDRQ: TDateTimeField;
    ADOTable1PICTURE: TBlobField;

  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  CustomerData: TCustomerData;

implementation

{$R *.DFM}

 

end.

{===========Unit23.pas===============}

unit Unit23;

interface

uses Windows, SysUtils, Messages, Classes, Graphics, Controls,
  StdCtrls, ExtCtrls, Forms, Quickrpt, QRCtrls;

type
  TIdearRpt = class(TQuickRep)
    PageFooterBand1: TQRBand;
    PageHeaderBand1: TQRBand;
    QRLabel1: TQRLabel;
    QRLabel2: TQRLabel;
    QRLabel3: TQRLabel;
    QRDBText15: TQRDBText;
    QRDBText17: TQRDBText;
    QRDBText19: TQRDBText;
    QRDBText13: TQRDBText;
    QRLabel46: TQRLabel;
    QRLabel47: TQRLabel;
    TitleBand1: TQRBand;
    QRShape1: TQRShape;
    QRShape2: TQRShape;
    QRShape3: TQRShape;
    QRShape4: TQRShape;
    QRShape5: TQRShape;
    QRShape6: TQRShape;
    QRLabel4: TQRLabel;
    QRLabel5: TQRLabel;
    QRLabel6: TQRLabel;
    QRShape7: TQRShape;
    QRShape8: TQRShape;
    QRLabel7: TQRLabel;
    QRLabel8: TQRLabel;
    QRLabel11: TQRLabel;
    QRLabel12: TQRLabel;
    QRDBText1: TQRDBText;
    QRDBText2: TQRDBText;
    QRDBText4: TQRDBText;
    QRDBText6: TQRDBText;
    QRDBText3: TQRDBText;
    QRShape9: TQRShape;
    QRLabel9: TQRLabel;
    QRDBText5: TQRDBText;
    QRShape17: TQRShape;
    QRShape22: TQRShape;
    QRShape23: TQRShape;
    QRShape24: TQRShape;
    QRShape25: TQRShape;
    QRShape26: TQRShape;
    QRShape27: TQRShape;
    QRShape10: TQRShape;
    QRShape11: TQRShape;
    QRShape12: TQRShape;
    QRShape13: TQRShape;
    QRShape18: TQRShape;
    QRShape19: TQRShape;
    QRLabel10: TQRLabel;
    QRLabel13: TQRLabel;
    QRLabel14: TQRLabel;
    QRLabel15: TQRLabel;
    QRLabel16: TQRLabel;
    QRLabel17: TQRLabel;
    QRLabel18: TQRLabel;
    QRLabel19: TQRLabel;
    QRLabel20: TQRLabel;
    QRLabel21: TQRLabel;
    QRLabel22: TQRLabel;
    QRLabel23: TQRLabel;
    QRLabel24: TQRLabel;
    QRLabel32: TQRLabel;
    QRLabel33: TQRLabel;
    QRLabel34: TQRLabel;
    QRLabel35: TQRLabel;
    QRLabel36: TQRLabel;
    QRShape20: TQRShape;
    QRLabel37: TQRLabel;
    QRLabel38: TQRLabel;
    QRLabel41: TQRLabel;
    QRLabel42: TQRLabel;
  

Tags:

相关文章

    文章评论

    最 近 更 新
    热 点 排 行
    Js与CSS工具
    代码转换工具
    
    <