保存RAVE报表为HTML
直接保存RAVE报表为HTML,需要TRvProject,TRvNDRWriter,TRvRenderHTML这三个
部件和TMemoryStream类!
在Rave报告设计器中还需要这样一个步骤!
(1)在右侧对象树面版中选择对应的Report!
(2)通过左侧的对象属性面板修改对应Report的PageList属性,[Add Page]把所需要的页加
入到 Page List 中!
如果不进行如上步骤,将只会生成第一页!
源代码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, RpRender, RpRenderHTML, RpBase, RpFiler, RpDefine,
RpRave;
type
TForm1 = class(TForm)
RvProject1: TRvProject;
RvNDRWriter1: TRvNDRWriter;
RvRenderHTML1: TRvRenderHTML;
Button1: TButton;
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'); //将报表数据调到内存流中
RvRenderHTML1.OutputFileName:='test.html'; //存放的文件名
RvRenderHTML1.Render(NDRStream); //将内存流保存成HTML格式
ShowMessage('生成报表文件成功!');
except
ShowMessage('生成报表文件错误!');
end;
end;
end.