Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
  1. 在 Visual Studio Windows 程序中,从 Visual Studio 工具箱中拖动Viewer控件到 Windows 窗体上。
  2. 将查看器的Dock属性设置为Fill
  3. 双击窗体的标题栏,创建Form_Load事件的事件处理方法。
  4. 在 Form_Load 事件中,添加如下所示代码,以运行报表并将其显示在查看器。

Visual Basic.NET中的代码

加载页面/RDL报表

将以下 Visual Basic. NET 代码粘贴到 Form_Load 中

Dim file_name As String = "..\..\PageReport1.rdlx"

Dim pageReport As New GrapeCity.ActiveReports.PageReport(New System.IO.FileInfo(file_name))

Dim pageDocument As New GrapeCity.ActiveReports.Document.PageDocument(pageReport)

Viewer1.LoadDocument(pageDocument)

加载基于代码的区域报表

将以下 Visual Basic. NET 代码粘贴到 Form_Load 中

Dim sectionReport As New SectionReport1()

Viewer1.LoadDocument(sectionReport)

 

加载基于模板的区域报表

将以下 Visual Basic. NET 代码粘贴到 Form_Load 中

Dim sectionReport As New GrapeCity.ActiveReports.SectionReport()

Dim xtr As New System.Xml.XmlTextReader("..\..\SectionReport1.rpx")

sectionReport.LoadLayout(xtr)

xtr.Close()

Viewer1.LoadDocument(sectionReport)

 

C#中的代码

加载页面/RDL报表

将以下 C# 代码粘贴到 Form_Load 中

string file_name = @"..\..\PageReport1.rdlx";

GrapeCity.ActiveReports.PageReport pageReport = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(file_name));

GrapeCity.ActiveReports.Document.PageDocument pageDocument = new GrapeCity.ActiveReports.Document.PageDocument(pageReport);

viewer1.LoadDocument(pageDocument);

 

加载基于代码的区域报表

将以下 C# 代码粘贴到 Form_Load 中

SectionReport1 sectionReport = new SectionReport1();

viewer1.LoadDocument(sectionReport);

 

加载基于模板的区域报表

将以下 C# 代码粘贴到 Form_Load 中

GrapeCity.ActiveReports.SectionReport sectionReport = new GrapeCity.ActiveReports.SectionReport();

System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(@"..\..\SectionReport1.rpx");

sectionReport.LoadLayout(xtr);

xtr.Close();

viewer1.LoadDocument(sectionReport);