上一篇 | 下一篇

在Rave报表中打印TeeChart图表

发布: 2008-6-26 17:58 | 作者: admin | 来源: | 查看: 10次

(1) 在Delphi 7开始一个新项目。

(2) 放置一个TChart部件在窗体上,增加一个TPieSeries系列。

(3) 增加如下的FormCreate过程。

procedure TForm1.FormCreate(Sender: TObject);

begin

Series1.FillSamplevalues(5);

end;

(4) 放置一个TRvCustomConnection部件在窗体上。完成TRvCustomConnection部件的两个

事件过程如下:

procedure TForm1.RvCustomConnection1GetRow(

Connection: TRvCustomConnection);

begin

// Chart is the name of the TChart component you are wanting to print

WriteChartData(Connection, Chart1);

end;

procedure TForm1.RvCustomConnection1GetCols(

Connection: TRvCustomConnection);

begin

with Connection do

begin

// PieChart is the name of the DataField that you will use in Rave

WriteField('PieChart', dtGraphic, 30, '', '');

end; { with }

end;

(5) 为了让Rave可视报表编辑器能够识别TRvCustomConnection部件,请直接在Delphi 7.0

的IDE中运行应用程序。

(6) 打开Rave可视报表编辑器,创建一个新的DataView,使之与TRvCustomConnection部件

连接。

(7) 放置一个metafile部件到你需要的页面,设定metafile部件的DataView和DataField属

性,使之与前面的DataView进行挂接。

(8) 保存报表项目文件后,退出Rave可视报表编辑器。

(9) 关闭正在运行的应用程序。

(10) 回到Delphi 7.0的IDE环境,增加TRvProject和TRvSystem部件,并把两者挂接。设定

TRvProject的ProjectFile属性为前面保存的Rave报表项目文件。

(11) 增加一个按钮,使之调用 RvProject1.execute过程。

(12) 至此,在Rave报表中就可以打印TeeChart图表了!

unit Unit1;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, RpDefine, RpCon, RpBase, RpSystem, RpRave, TeEngine, Series,

ExtCtrls, TeeProcs, Chart,RpTChart, StdCtrls;

type

TForm1 = class(TForm)

RvCustomConnection1: TRvCustomConnection;

RvProject1: TRvProject;

RvSystem1: TRvSystem;

Chart1: TChart;

Series1: TPieSeries;

Button1: TButton;

procedure RvCustomConnection1GetRow(Connection: TRvCustomConnection);

procedure RvCustomConnection1GetCols(Connection: TRvCustomConnection);

procedure Button1Click(Sender: TObject);

procedure FormCreate(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);

begin

Series1.FillSamplevalues(5);

end;

procedure TForm1.RvCustomConnection1GetRow(

Connection: TRvCustomConnection);

begin

// Chart is the name of the TChart component you are wanting to print

WriteChartData(Connection, Chart1);

end;

procedure TForm1.RvCustomConnection1GetCols(

Connection: TRvCustomConnection);

begin

with Connection do

begin

// PieChart is the name of the DataField that you will use in Rave

WriteField('PieChart', dtGraphic, 30, '', '');

end; { with }

end;

procedure TForm1.Button1Click(Sender: TObject);

begin

RvProject1.execute;

end;

end.

字号: | 推荐给好友

21/212>

评分:0

我来说两句

网络推荐