zoukankan      html  css  js  c++  java
  • DLL封装ReportMachine/FastReport报表

    如果有报表文件兼容性问题,可以参考下面的方法来将某版本的报表封装到DLL中来使用。
    首先建立一个DLL工厂,然后建立一个主窗体,在窗体中放入报表相关的控件。

    为了传入变量,我们简单定义一个变量名称/值对应用的对象:

    //变量对应,可以用于变量和对象
      RMVariants
    =class
        VarName:
    string;
        VarValue:
    string;
      
    end;

    然后定义一个输出函数:

    procedure ShowReport(vFile:string;vDSList:TList;vVarValueList:TList=nil);stdcall;
    var
      i:Integer;
      aDataSet:TADODataSet;
      aRMDBDataSet:TRMDBDataSet;
      aRMVariants:RMVariants;
    begin
      
    try
        frmReport:
    =TfrmReport.Create(nil);
        
    with frmReport do
        
    begin
          RMReport1.LoadFromFile(vFile);

          
    //创建结果集列表
          
    if vDSList<>nil then
          
    for I := 0 to vDSList.Count - 1 do
          
    begin
            aDataSet:
    =TADODataSet.Create(nil);
            aDataSet.Clone(TADODataSet(vDSList[i]));
            aDataSet.Name:
    =TDataSet(vDSList[i]).Name;

            aRMDBDataSet:
    =TRMDBDataSet.Create(nil);
            aRMDBDataSet.DataSet:
    =aDataSet;
            aRMDBDataSet.Name:
    ='RMDB'+aDataSet.Name;

            InsertComponent(aDataSet);
            InsertComponent(aRMDBDataSet);
          
    end;

          
    //对变量进行赋值
          
    if vVarValueList<>nil then
          
    for I := 0 to vVarValueList.Count - 1 do
          
    begin
            aRMVariants:
    =RMVariants(vVarValueList[i]);
            RMReport1.Dictionary.Variables[aRMVariants.VarName] :
    =aRMVariants.VarValue;
          
    end;

          RMReport1.ShowReport
        
    end;
      
    finally
        frmReport.Free;
      
    end;
    end;

    然后在需要的时候调用该DLL即可。

    上面代码使用了ADO,为了更通用,可以使用ClientDataSet来处理数据,在窗体中放在TDataSetProvider和TClientDataSet来处理结果集,如果不想发布Midas.dll,可以引用单元MidasLib

    注:以上示例使用了ReportMachine,同样适用于FastReport.

  • 相关阅读:
    Ceph 之RGW Cache
    Ceph 之RGW Pub-Sub Module
    Ceph 之RGW Data Layout
    RocksDB 之Write Ahead Log(WAL)
    Ceph 之 Background on http frontends
    Ceph 之Multisite 下的bucket reshard
    Ceph之PG数调整
    Ceph之对象存储网关RADOS Gateway(RGW)
    window mysql重启、忘记密码等操作
    selenium处理HTML5视频播放未能自动播放解决办法
  • 原文地址:https://www.cnblogs.com/GarfieldTom/p/1740553.html
Copyright © 2011-2022 走看看