Glossary Item Box
To write the code to save a report as an RPX file in Visual Basic
To write the code to save a report as an RPX file in C#
The following example shows what the code for the method looks like.
' Visual Basic
Dim rpt As New ActiveReport1()
Private Sub saveRPX()
rpt.Run()
rpt.SaveLayout(Application.StartupPath + "\\NewRPX.RPX")
End Sub
//C#
private void saveRPX()
{
ActiveReport1 rpt = new ActiveReport1();
rpt.Run();
rpt.SaveLayout(Application.StartupPath + "\\NewRPX.RPX");
}
Note: The SaveLayout method uses utf-16 encoding when you save to a stream, and utf-8 encoding when you save to a file.
To write the code to load the saved RPX into the ActiveReports viewer in Visual Basic
To write the code to load the saved RPX into the ActiveReports viewer in C#
The following example shows what the code for the method looks like.
' Visual Basic
Dim rpt As New ActiveReport1()
Private Sub loadRPX()
rpt.LoadLayout(Application.StartupPath + "\\NewRPX.RPX")
Viewer1.Document = rpt.Document
rpt.Run()
End Sub
//C#
private void loadRPX()
{
ActiveReport1 rpt = new ActiveReport1();
rpt.LoadLayout(Application.StartupPath + "\\NewRPX.RPX");
viewer1.Document = rpt.Document;
rpt.Run();
}
Note: When saving to an RPX file, be sure to save the report before it runs. Saving the layout after the report runs will cause any dynamic changes made to properties or sections to be saved in the layout. When calling SaveLayout inside the report's code, use the ReportStart event. Also note that when saving a report layout, only the code in the script editor will be saved to the file. Any code behind the report in the .cs or .vb file will not be saved to the RPX file.
See Also |
Getting Started | Loading an Existing Report Layout
Copyright © 2004-2005 Data Dynamics, Ltd. All rights reserved.