您的位置: 首页-> 电脑文摘-> 程序设计-> Delphi/Pascal-> 正文

在Rave报表中打印TeeChart图表
作者佚名 来源InterNet 加入时间:2004-11-23
在Rave报表中打印TeeChart图表

(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.
 


[文章录入员:fightter]

相关文章 相关软件:
::PCBOOKCN'ADS::


::Delphi/Pascal::
C/C++/VC
C++Builder
Basic/VB类
Delphi/Pascal
Java编程
FORTRAN
其它
::阅读排行::
·Delphi与Excel的亲密接...
·Delphi实现串口通信的常用的...
·DELPHI下的多线程程序设计(...
·Delphi中初始化.Ini文件...
·Delphi中用于读写(I/O)...
·谈谈Delphi中的类和对象
·Delphi编译错误中文手册
·Delphi中关于TApplic...
·OPENGL图形程序设计
·SQL的基本操作