ActiveReports Developer 7
Save and Load RDF Report Files
See Also Support Forum
ActiveReports Developer 7 > ActiveReports Developer Guide > How To > Section Report How To > Save and Load RDF Report Files

Glossary Item Box

ActiveReports Developer allows reports to be saved in 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. You can save a report to an RDF file and load it into the viewer control.

ShowTo save a report as a static RDF file

  1. Double-click the title bar of the Windows Form to create an event-handling method for the Form_Load event.
  2. Add the following code to the handler to save the report.

    ShowTo write the code in Visual Basic.NET

    Visual Basic.NET code. Paste INSIDE the Form_Load event. Copy Code
    Dim rpt As New YourReportName()
    rpt.Document.Save(Application.StartupPath + "\NewRDF.RDF")
    

    ShowTo write the code in C#

    C# code. Paste INSIDE the Form_Load event. Copy Code
    YourReportName rpt = new YourReportName();
    rpt.Document.Save(Application.StartupPath + "\\NewRDF.RDF");
    

ShowTo load a saved RDF file into the ActiveReports viewer

  1. Double-click the title bar of the Windows Form to create an event-handling method for the Form_Load event.
  2. Add the following code to the handler to load the saved report.

    ShowTo write the code in Visual Basic.NET

    Visual Basic.NET code. Paste INSIDE the Form_Load event. Copy Code
    Viewer1.Document.Load("Location of the .RDF File")
    

    ShowTo write the code in C#

    C# code. Paste INSIDE the Form_Load event. Copy Code
    viewer1.Document.Load(@"Location of the .RDF File");
    
Note: 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.

ShowTo save or load report files to a memory stream

  1. Double-click the title bar of the Windows Form to create an event-handling method for the Form_Load event.
  2. Add the following code to the handler to save the report to a memory stream and load the memory stream into the ActiveReports viewer.

    The following examples show what the code for the method looks like.

    ShowTo 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 YourReportName()
    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)
    

    ShowTo write the code in C#

    C# code. Paste INSIDE the Form_Load event. Copy Code
    System.IO.MemoryStream strm = new System.IO.MemoryStream();
    YourReportName rpt = new YourReportName();
    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);
    

See Also

©2014. ComponentOne, a division of GrapeCity. All rights reserved.