CustomConnection部件的使用
对于CustomConnection的使用,资料极少!今天我研究了一阵德文资料(先把德文转换为英
文)!
取得了一些进展!
CustomConnection是自定义德连接组件,通常用于获取非数据库的数据类型,比如内存数组
和二进制记录文件等。
在下面的例子中,我建立了一个IntArray数组,通过CustomConnection部件把数组数据传送
到RAVE报表中进行打印。
GetCols事件是用于字段的定义
procedure TForm1.RvCustomConnection1GetCols(
Connection: TRvCustomConnection);
begin
// data fields define
// 各个字段的定义
connection.WriteField('Name',dtInteger,30,'','');
end;
GetRow事件用于输出具体的每行数据
procedure TForm1.RvCustomConnection1GetRow(
Connection: TRvCustomConnection);
Var
i:Integer;
begin
// actual data to the report hand over
//输出每行数据
Connection.WriteIntData('',intArray[CUrID]);
INC(CUrID);
end;
Open事件用于确定要输出数据的总行数
procedure TForm1.RvCustomConnection1Open(Connection: TRvCustomConnection);
begin
// number of data lines; There here header data only 1
// 要输出数据的总行数
Connection.DataRows:= 100;
end;
程序的源代码
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, RpCon, RpBase, RpSystem, RpDefine, RpRave;
type
TForm1 = class(TForm)
RvProject1: TRvProject;
RvSystem1: TRvSystem;
RvCustomConnection1: TRvCustomConnection;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure RvCustomConnection1Open(Connection: TRvCustomConnection);
procedure RvCustomConnection1GetRow(Connection: TRvCustomConnection);
procedure RvCustomConnection1GetCols(Connection: TRvCustomConnection);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1:TForm1;
CUrID:Integer;
IntArray: Array[1..100] of integer;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
i : integer;
begin
For i := 1 to 100 do
IntArray[i] := i;
CUrID:=1;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
RvProject1.Execute;
end;
procedure TForm1.RvCustomConnection1Open(Connection: TRvCustomConnection);
begin
// number of data lines; There here header data only 1
// 要输出数据的总行数
Connection.DataRows:= 100;
end;
procedure TForm1.RvCustomConnection1GetRow(
Connection: TRvCustomConnection);
Var
i:Integer;
begin
// actual data to the report hand over
//输出每行数据
Connection.WriteIntData('',intArray[CUrID]);
INC(CUrID);
end;
procedure TForm1.RvCustomConnection1GetCols(
Connection: TRvCustomConnection);
begin
// data fields define
// 各个字段的定义
connection.WriteField('Name',dtInteger,30,'','');
end;
end.
|