用Delphi开发报表打印的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===============

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值