Scripts Overview | .NET Reporting Tools (2024)

  • 6 minutes to read

You can write scripts within report elements’ event handlers to perform custom calculations over your report’s data. Scripts run when the corresponding event occurs (for instance, a mouse click).

Important

Report scripts are not secure. We recommend that you use expression bindings instead.

The scripts are initially disabled in Web applications and all ASP.NET Core applications. Review the following help topic for information on how to enable scripts: Scripts Security. In ASP.NET Core applications, you should also install the Microsoft.CodeAnalysis NuGet package to enable report script execution.

Note

Blazor WebAssembly Reporting applications do not support scripts.

Script Options

You can use the XtraReport.ScriptLanguage property to specify the language to write scripts in the report. Report Designers support the following script languages:

  • C#
  • Visual Basic .NET
  • JScript .NET (not available in .NET applications)

Note that the script language does not depend on the language used to create the report.

Report scripts provide access to the following assemblies:

  • Core assemblies that all reporting applications reference:

    • DevExpress.Charts.v24.1.Core
    • DevExpress.Data.v24.1
    • DevExpress.Office.v24.1.Core
    • DevExpress.PivotGrid.v24.1.Core
    • DevExpress.Printing.v24.1.Core
    • DevExpress.RichEdit.v24.1.Core
    • DevExpress.Sparkline.v24.1.Core
    • DevExpress.XtraCharts.v24.1
  • Standard .NET framework assemblies that all reporting applications reference:

    • Microsoft.CSharp.dll
    • System.dll
    • System.Data.dll
    • System.Xml.dll
    • System.Drawing.dll
    • System.Windows.Forms.dll
    • System.Core.dll
  • Other assemblies that are currently loaded into your application’s domain.

You can enable other assemblies in report scripts. List them in the XtraReport.ScriptReferences property at design time or in the XtraReport.ScriptReferencesString property at runtime. You can specify a path to an assembly as an absolute (full) path or a path relative to the directory where an application runs. All the listed assemblies are loaded into the application domain when report scripts are compiled.

If you modify specific classes in the loaded assemblies, these changes are not immediately applied to the Report Designer. You should reopen the Report Designer to reload assemblies. These changes are applied automatically only if you write scripts in the Visual Studio Report Designer and customize an assembly from the same solution.

Manage Scripts

A report and every report element has an individual set of script events. For instance, the XRChart control has the XRChartScripts.OnBoundDataChanged event that is specific to this control only, while the XRControl.BeforePrint event is declared at the base control’s level and is applicable to most report controls. The XRControl.Scripts collection provides access to all events that the selected report control supports.

At design time in Visual Studio, you can switch to the Properties window and expand the Scripts property. Select an event and choose (New) in the drop-down list. This opens the Scripts tab and adds the event handler’s template. This template uses the language that the XtraReport.ScriptLanguage property specifies.

Scripts Overview | .NET Reporting Tools (1)

The Scripts tab contains all scripts written for all report elements. You can choose a report element from the drop-down list on the left, and an event from the drop-down list on the right. This adds a new handler if it does not exist yet or navigates to the corresponding event handler if it is already specified.

Scripts Overview | .NET Reporting Tools (2)

You can write any syntactically correct code in scripts. You can declare new classes, variables, and methods.

Click the Validate button to check for errors in report scripts.

Scripts Overview | .NET Reporting Tools (3)

The Error List panel lists all found errors.

Scripts Overview | .NET Reporting Tools (4)

Click an error in the panel to navigate to the line that contains this error.

Refer to Debug Scripts in Visual Studio for information on how to debug report scripts.

Note

If you handle a report control’s event in code behind and write a script for the same event, the event in code behind is executed after the script event.

Intelligent Code Completion

Script editors support intelligent code completion for the C# and Visual Basic .NET script languages. Context-aware hints are displayed when you type a dot or press CTRL+spacebar.

Scripts Overview | .NET Reporting Tools (5)

Note

The WPF End-User Report Designer does not currently support this feature.

In the Visual Studio Report Designer, intelligent code completion always requires an Internet connection and supports only .NET Framework and DevExpress libraries deployed with the application.

For End-User Report Designers, you can either connect your machine to the Internet or register the local code completion engine (it also supports types defined in custom assemblies).

Do the following to activate the local code completion engine in your end-user reporting application:

  1. Right-click the References node in the Solution Explorer and select Manage NuGet Packages in the invoked context menu.

    Scripts Overview | .NET Reporting Tools (6)

  2. Select DevExpress 24.1 Local in the Package source drop-down list and go to the Browse page. Find the DevExpress.Reporting.CodeCompletion NuGet package and install it.

    Scripts Overview | .NET Reporting Tools (7)

  3. Call the CodeCompletionRequestManager.UseLocalEngine method at application startup.

    The local engine requires a storage for report layouts. You can use the predefined storage (the FileCodeCompletionContextStorage or InMemoryCodeCompletionContextStorage class) or provide your custom storage.

    • The UseLocalEngine() method without parameters activates an in-memory storage (InMemoryCodeCompletionContextStorage).

      • C#
      • VB.NET
      DevExpress.XtraReports.CodeCompletion.CodeCompletionRequestManager.UseLocalEngine();
    • The UseLocalEngine(ICodeCompletionContextStorage) method accepts a storage object as a parameter.

      The following code demonstrates how to pass the FileCodeCompletionContextStorage instance to store report layouts in the specified folder:

      • C#
      • VB.NET
      using DevExpress.XtraReports.CodeCompletion;using DevExpress.XtraReports.CodeCompletion.Storages;CodeCompletionRequestManager.UseLocalEngine(new FileCodeCompletionContextStorage("D:\\CodeCompletionContext"));

      You can also implement the ICodeCompletionContextStorage interface, create its instance and pass it to the method as the parameter.

To disable intelligent code completion, set the static SyntaxEditor.EnableCodeCompletion property to false.

Script Processing Mechanism

The reporting engine processes scripts as follows:

  1. Generates a temporary class in memory.

  2. Adds variables that correspond to the following items:

    • report;
    • report bands;
    • report controls;
    • calculated fields;
    • parameters;
    • styles;
    • control appearance;
    • data sources.

    The item’s Name property value defines the variable name. An exception occurs while the script runs if you do not specify the Name property.

    Note

    If the script code already contains a variable with the same name as a report item, a variable for this item is not generated. This functionality requires the DevExpress.CodeParser.v24.1.dll assembly. If this assembly is not added to the project’s reference list, a compilation error is raised.

  3. Cuts the using-like directives from the script code and adds them to the namespace that contains the temporary class.

  4. Places all the report scripts into the temporary class as methods.

  5. Compiles the resulting class in memory.

  6. Calls this class’s methods to execute the corresponding report scripts.

See Also

Scripts Security

Scripts Overview | .NET Reporting Tools (2024)
Top Articles
How to read news on Forex Factory
A New Set of Financial Instruments
English Bulldog Puppies For Sale Under 1000 In Florida
Katie Pavlich Bikini Photos
Gamevault Agent
Pieology Nutrition Calculator Mobile
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Compare the Samsung Galaxy S24 - 256GB - Cobalt Violet vs Apple iPhone 16 Pro - 128GB - Desert Titanium | AT&T
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Craigslist Dog Kennels For Sale
Things To Do In Atlanta Tomorrow Night
Non Sequitur
Crossword Nexus Solver
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Energy Healing Conference Utah
Geometry Review Quiz 5 Answer Key
Hobby Stores Near Me Now
Icivics The Electoral Process Answer Key
Allybearloves
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Pearson Correlation Coefficient
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Marquette Gas Prices
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Vera Bradley Factory Outlet Sunbury Products
Pixel Combat Unblocked
Movies - EPIC Theatres
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Mia Malkova Bio, Net Worth, Age & More - Magzica
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Topos De Bolos Engraçados
Sand Castle Parents Guide
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Hello – Cornerstone Chapel
Stoughton Commuter Rail Schedule
Nfsd Web Portal
Selly Medaline
Latest Posts
Article information

Author: Rev. Porsche Oberbrunner

Last Updated:

Views: 5826

Rating: 4.2 / 5 (53 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Rev. Porsche Oberbrunner

Birthday: 1994-06-25

Address: Suite 153 582 Lubowitz Walks, Port Alfredoborough, IN 72879-2838

Phone: +128413562823324

Job: IT Strategist

Hobby: Video gaming, Basketball, Web surfing, Book restoration, Jogging, Shooting, Fishing

Introduction: My name is Rev. Porsche Oberbrunner, I am a zany, graceful, talented, witty, determined, shiny, enchanting person who loves writing and wants to share my knowledge and understanding with you.