ActiveReports allows reports to be saved into their own standard format called an RDF file (Report Document Format). In this format, the data is static. The saved report displays the data that is retrieved when you run the report. Once a report has been saved to an RDF file, it can be loaded into the viewer control.
To save the report to RDF format in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Form load event. |
Copy Code |
---|---|
Dim rpt As New rptYourReportName() rpt.Run() rpt.Document.Save(Application.StartupPath + "\\NewRDF.RDF") |
To save the report to RDF format in C#
C# code. Paste INSIDE the Form load event. |
Copy Code |
---|---|
ActiveReport1 rpt = new ActiveReport1(); rpt.Run(); rpt.Document.Save(Application.StartupPath + \\NewRDF.RDF); |
The Windows Form Viewer can display RDF files made with any version of ActiveReports, including COM versions. The FlashViewer viewer type of the WebViewer (Professional Edition) may be able to display RDF files made with previous versions, but this is not guaranteed for every RDF.
To load an RDF file in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Form load event. |
Copy Code |
---|---|
Viewer1.Document.Load(Application.StartupPath + \\NewRDF.RDF) |
To load an RDF file in C#
C# code. Paste INSIDE the Form load event. |
Copy Code |
---|---|
viewer1.Document.Load(Application.StartupPath + \\NewRDF.RDF); |
The following examples show what the code for the method looks like.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Form Load event. |
Copy Code |
---|---|
Dim strm As New System.IO.MemoryStream() Dim rpt As New rptMemoryStream() rpt.Run() rpt.Document.Save(strm) Dim theBytes(strm.Length) As Byte strm.Read(theBytes, 0, Int(strm.Length)) strm.Position = 0 Viewer1.Document.Load(strm) |
To write the code in C#
C# code. Paste INSIDE the Form Load event. |
Copy Code |
---|---|
System.IO.MemoryStream strm = new System.IO.MemoryStream(); rptMemoryStream rpt = new rptMemoryStream(); rpt.Run(); rpt.Document.Save(strm); byte[] theBytes = new byte[strm.Length]; strm.Read(theBytes, 0, (int)strm.Length); strm.Position =0; viewer1.Document.Load(strm); |