如何在Delphi表单上预览好评如潮的报告? 我有一个页面控件有2页:在第一页上,用户输入一些数据(名称,地址......),我希望在第二页上预览使用第一页数据生成的报告。
答案 0 :(得分:2)
您可以使用TRvRenderPreview向任何TScrollBox渲染预览:
使用TRvSystem:
RvRenderPreview1.ScrollBox := ScrollBox1; // a scrollbox on a TTabSheet
RvSystem1.DefaultDest := rdFile;
RvSystem1.SystemSetups := RvSystem1.SystemSetups - [ssAllowSetup];
RvSystem1.RenderObject := RvRenderPreview1;
RvSystem1.DoNativeOutput := false;
RvSystem1.Execute;
答案 1 :(得分:2)
您可以使用TRvNDRWriter组件而不是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;
答案 2 :(得分:0)
我使用过打印预览,但它并不完全相同,但在我的应用程序中它就足够了。我不知道是否可以嵌入页面内部控件。
答案 3 :(得分:0)
使用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;