How can I preview a rave report on a Delphi form? I have a page control with 2 pages: on the first one the user enter some data (name, address...) and I want on the second page to preview the report generated with the data from the first page.
Delphi - preview a Rave report on the form
4.8k views Asked by Chris Ghenea At
4
There are 4 answers
0
On
You can use the TRvNDRWriter component instead of the TRvSystem.
procedure TForm1.Button1Click(Sender: TObject);
begin
RvProject1.Execute;
RvRenderPreview1.Render;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
ms: TMemoryStream;
begin
// RvNDRWriter1.StreamMode := smUser;
// RvRenderPreview1.ScrollBox := ScrollBox1;
ms := TMemoryStream.Create;
RvNDRWriter1.Stream := ms;
RvRenderPreview1.NDRStream := ms;
end;
0
On
Using TRvProject + TRvNDRWriter + TRvRenderPreview + TMemoryStream + TScrollBox
procedure TForm1.FormCreate(Sender: TObject);
begin
FNdrStream := TMemoryStream.Create;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
FNdrStream.Free;
end;
procedure TForm1.btnPreviewClick(Sender: TObject);
begin
//load report project file. You can use stored RAV instead
rvProject.ProjectFile := 'C:\ExecutaveisGerados\Exemplos\sampleRave\sampleRave.rav';
rvProject.Open;
//tells rave we will write the report result to a NDR
rvProject.Engine := rvNdrWriter;
//ensure empty memory stream
FNdrStream.Clear;
//tells NDRWriter where to store ndr file (memory stream)
rvNdrWriter.StreamMode := smUser;
rvNdrWriter.Stream := FNdrStream;
//execute the report using the NDRWriter. Now the Stream holds the NDR file
rvProject.Execute;
//tells RenderPreview where to display
rvRenderPreview.ScrollBox := sbReportPreview;
//display NDR file from memory stream
rvRenderPreview.Render(FNdrStream);
end;
You can render a preview to any TScrollBox with a TRvRenderPreview:
With a TRvSystem: