ActiveReports allows you to use scripting to provide ease in reporting functionality. Scripting permits reports saved to an RPX file to contain code. This characteristic allows the options of stand-alone reporting and web reporting without requiring .vb or .cs files. By including scripting when the report is saved as an RPX file, it can later by loaded, run and displayed directly to the viewer control without using the designer. Scripting can also be used in conjunction with RPX files to allow distributed reports to be updated without recompiling.
Scripting can be used by adding C# code to the script editor at design time or by using rpt.Script at run time. The script is then saved to the RPX file.
The AddNamedltem and AddCode methods are used to add items to the report* s script. By using AddNamedltem or AddCode, code elements from inside the .NET project can be used inside the scripts. By using AddNamedltem, scripts can become aware of functions in a class contained in the .NET project. By using AddCode, actual code segments can be added to the script at run time. Since the RPX file can be read with any text editor, AddCode or AddNamedltem can be used to add secure information to a project, such as a connection string.
AddScriptReference can be used to add an assembly reference to the script. This will allow users to add a reference in the script to access assemblies in their projects. AddScriptReference is only needed if the script accesses assemblies that are not already initialized in the project. For example, to access "System.Data.DataSet" inside the script, you would need to add a reference by calling "rpt.AddScriptReference("System.Data.Dll")".
Was this article helpful?