作为《Delphi
中使用RAVE报表》的最后
整理一些技巧给大家
.设计好的Rave报表文件如何打包到EXE文件中?
在Rvproject的属性中有一个StoreRav只要load对应的rav文件即可!同时最好把对应rvproject的ProjectFile属性清空
.如何显示中文化的打印预览对话框?
)拷贝C:\Rave\Source目录中的RpFormPreviewpas和RpFormPreviewdfm到对应的项
目目录中
)把RpFormPreviewpas加入到对应的项目文件中把对应窗体的名字从
RavePreviewForm更改为SCRavePreviewForm将文件RpFormPreviewpas另存为
SCFormPreviewpas
3)把窗体SCRavePreviewForm中的对应文字从英文更改为中文
4)在主窗体上加上 RvProject和 RvSystem部件通过设定RvProjectEngine为
RvSystem部件来把两者挂接
5)设置RvSystem部件的OverridePreview事件过程为以下代码
procedure TFormRvSystemOverridePreview(ReportSystem: TRvSystem;
OverrideMode: TOverrideMode; var OverrideForm: TForm);
begin
Case OverrideMode Of
omCreate:
Begin
OverrideForm := TSCRavePreviewFormCreate(self);
//OverrideFormCaption := ReportSystemTitlePreview;
OverrideFormWidth := ReportSystemSystemPreviewFormWidth;
OverrideFormHeight := ReportSystemSystemPreviewFormHeight;
OverrideFormWindowState := ReportSystemSystemPreviewFormState;
(OverrideForm As TSCRavePreviewForm)ReportSystem := ReportSystem;
End;
omShow:
Begin
ReportSystemSystemPreviewInitPreview((OverrideForm As
TSCRavePreviewForm)RvRenderPreview);
If Assigned(ReportSystemOnPreviewSetup) Then
Begin
ReportSystemOnPreviewSetup((OverrideForm As
TSCRavePreviewForm)RvRenderPreview);
End; { if }
(OverrideForm As TSCRavePreviewForm)InputFileName :=
ReportSystemSystemFilerFilename;
(OverrideForm As TSCRavePreviewForm)InputStream :=
ReportSystemSystemFilerStream;
(OverrideForm As TSCRavePreviewForm)InitFromRPSystem;
(* *)
If soPreviewModal In ReportSystemSystemOptions Then
Begin
OverrideFormShowModal;
End
Else
Begin
OverrideFormShow;
End; { else }
End;
omWait:
Begin
If Not (soPreviewModal In ReportSystemSystemOptions) Then
Begin
// Wait for close
Repeat
Sleep();
ApplicationProcessMessages;
Until Not OverrideFormVisible;
End; { if }
End;
omFree:
Begin
If (ReportSystemSystemFilerStreamMode In [smTempFile smFile]) Then
Begin
(OverrideForm As TSCRavePreviewForm)RvRenderPreviewNDRStreamFree;
(OverrideForm As TSCRavePreviewForm)RvRenderPreviewNDRStream :=
Nil;
End; { if }
FreeAndNil(OverrideForm);
End;
End; { case }
end;
6)编译运行这个项目其打印预览窗口就会变成中文的了
备注这种方式进行中文化不会受到RAVE版本升级的影响
.如何显示中文化的打印设置对话框?
1)拷贝C:\Rave\Source目录中的RpFormSetuppas和RpFormSetupdfm到对应的项目目
录中
2)把RpFormSetuppas加入到对应的项目文件中把对应窗体的名字从RPSetupForm更改
为SCSetupForm将文件RpFormSetuppas另存为SCFormSetuppas
3)把窗体SCSetupForm中的对应文字从英文更改为中文
4)在主窗体上加上 RvProject和 RvSystem部件通过设定RvProjectEngine为
RvSystem 部件来把两者挂接
5)设置RvSystem部件的OverrideSetup事件过程为以下代码
procedure TFormRvSystemOverrideSetup(ReportSystem: TRvSystem;
OverrideMode: TOverrideMode; var OverrideForm: TForm);
begin
case
OverrideMode of
omCreate:
begin
OverrideForm := TSCSetupFormCreate(nil);
//OverrideFormCaption := RvSystemTitleSetup;
(OverrideForm as TSCSetupForm)ReportSystem := ReportSystem;
end;
omShow:
begin
with OverrideForm as TSCSetupForm ReportSystem do
begin
PreviewSetup := False;
Aborted := ShowModal = mrCancel;
end;
end;
omWait:
begin
{because showModal: no wait necessary!}
end;
omFree:
begin
OverrideFormFree;
end;
end;
end;
6)编译运行这个项目其打印设置对话框就会变成中文的了!
这种方式进行中文化不会受到RAVE版本升级的影响!对于其它对话框应该可以同法炮制吧!
.如何自已做预览窗口?
1)创建一个窗口在上面放RvProject组件RvNDRWriter组件RvRenderPreview组件和ScrollBox组件设定以下几个部件间的联系关系
RvProjectEngine:=RvNDRWriter;
RvRenderPreviewScrollBox:=ScrollBox;
2)设定RvNDRWriterfilename为 demondr 进行预览的代码为
var
NDRStream:TMemoryStream;
begin
//建立内存流
NDRStream:=TMemoryStreamCreate
//输出报表数据
RvProjectExecute
//将报表数据调入内存流中供预览
NDRStreamLoadFromFile(demondr);
//预览相应的报表使用的是相应的内存流
RvRenderPreviewRender(NDRStream);
ShowButton();
end;
<![if !supportEmptyParas]> <![endif]>
要想在你的项目中很好的应用RAVE做好报表更多的内容参考\Rave\Docs\下的RAVE手册
<![if !supportEmptyParas]> <![endif]>
<![if !supportEmptyParas]> <![endif]>
<![if !supportEmptyParas]> <![endif]>