Application Development

Software technique, Skills & Applications

Rave December 3, 2008

meetme @ 4:36 pm

Rave不能运行

检查是否有多个打印机,通常不支持多打印机

 

RAVE中如何设置纸张大小 http://www.pcbookcn.com/article/1290.htm

RAVE中如何设置纸张大小

我研究了一下,初步的方法如下:

1.在RAVE报表设计器中更改缺省报表页的尺寸的菜单路径为:
Edit–>Preferences–>选择defaults选项–>更改Paper Size
如上更改的缺省报表页面的尺寸仅对此后新生成的页有效!

2.在RAVE报表设计器中更改已经存在的页的尺寸的方法为:
从右边的树状对象库中选定对应的页,通过属性编辑器更改
页的PaperSize属性为所需要的大小!

3.在应用程序中,采用以下代码应该可以改变页的尺寸。

procedure TForm1.Button1Click(Sender: TObject);
var
MyPage: TRavePage;
begin
RvProject1.Open;

With RvProject1.ProjMan do
begin
MyPage := FindRaveComponent(‘Report1.Page1′,nil) as TRavePage;  //查找
PAGE
MyPage.PaperSize:=DMPAPER_A4;                                   //设置报
表页的尺寸

end; { with }

RvProject1.ExecuteReport(‘Report1′);
RvProject1.Close;
end;

<!–[if gte mso 9]> Normal 0 false false false MicrosoftInternetExplorer4 <![endif]–><!–[if gte mso 9]> <![endif]–> <!– /* Font Definitions */ @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:宋体; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:”\@SimSun”; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:”"; margin:0cm; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:”Times New Roman”; mso-fareast-font-family:SimSun;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:35.4pt; mso-footer-margin:35.4pt; mso-paper-source:0;} div.Section1 {page:Section1;} –>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:”Table Normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:”";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:”Times New Roman”;
mso-fareast-font-family:”Times New Roman”;
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}

保存RAVE报表为PDF文件

 

直接保存RAVE报表为PDF,需要TRvProjectTRvNDRWriterTRvRenderPDF这三个部
件和TMemoryStream类!

Rave报告设计器中还需要这样一个步骤!

(1)在右侧对象树面版中选择对应的Report!
(2)通过左侧的对象属性面板修改对应ReportPageList属性,[Add Page]把所需要的页加
入到 Page List 中!

如果不进行如上步骤,将只会生成第一页!

生成的pdf文件,英文没有任何问题,中文是乱码,经对源代码的研究主要是中文字
体处理方面有问题,本人正在通过网络需求高手解决!

——————————————————————————–
——————————

源代码如下:

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, RpRender, RpRenderPDF, RpBase, RpFiler, RpDefine, RpRave,
StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
RvProject1: TRvProject;
RvNDRWriter1: TRvNDRWriter;
RvRenderPDF1: TRvRenderPDF;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
Var
NDRStream:TMemoryStream;
begin
rvproject1.Engine:=RvNDRWriter1;

rvproject1.Open;
rvproject1.SelectReport(‘report1′,true);        //选择要打印的报表

RvNDRWriter1.FileName:=’yydemo.ndr’;
RvNDRWriter1.StreamMode:=smfile;    //smMemory;   //保存成文件

try
NDRStream:=TMemoryStream.Create;              //建立内存流
rvproject1.Execute;                           //输出报表数据

NDRStream.LoadFromFile(‘yydemo.ndr’);         //将报表数据调到内存流中

RvRenderPDF1.OutputFileName:=’test.pdf’;    //存放的文件名
RvRenderPDF1.Render(NDRStream);              //将内存流保存成PDF格式
ShowMessage(‘生成报表文件成功!’);
except
ShowMessage(‘生成报表文件错误!’);
end;
end;

end.

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部件的DataViewDataField
性,使之与前面的DataView进行挂接。

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

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

(10) 回到Delphi 7.0IDE环境,增加TRvProjectTRvSystem部件,并把两者挂接。设定
TRvProjectProjectFile属性为前面保存的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.