Script Development

Scripting is what significantly enhances the functionality of aqua reports. With scripting you can enhance the report not only by relying on the data within aqua but by being able to add data by reading databases or files. You also have the option to save a copy of the report in a certain network drive or to choose not to print certain elements on every event band iteration.

To execute a script on a certain event, you need to add a script function for the event of the element. You can do this by linking a script method to the “Behaviour/Scripts” property. All events that the element selected throws are listed within this property. These can vary for different types of elements.

To change to the scripts view, click on the Scripts button at the bottom left of the report designer.

Here, you can add some functionality to your report. For example, if you only want to print a label every second time, you can add the following code:

During script development, you can make use of the entire .NET library, and you reference all elements and their respective properties within the report.

Example: Apply different colour to areas

The appearance can be modified with the event “OnPrintPage”

private void OnPrintOnPage(object sender, DevExpress.XtraReports.UI.PrintOnPageEventArgs e)
{
    string t = ((XRLabel)sender).Text; // Get the label's text.
    t = t.Substring(0, t.Length - 1); // Remove the last character from the text 
    int value = int.Parse(t); // Parse the text into an integer.

    if (value < 20)
    {
        ((XRLabel)sender).ForeColor = Color.FromArgb(255, 0, 0); // Set the label's forecolor to red if the value is less than 20.
    }
    else if (value > 80)
    {
        ((XRLabel)sender).ForeColor = Color.FromArgb(0, 110, 0); // Set the label's forecolor to green if the value is greater than 80.
    }
    else
    {
        ((XRLabel)sender).ForeColor = Color.FromArgb(255, 165, 0); // Set the label's forecolor to orange if the value is between 20 and 80.
    }
}

The appearance can also be modified using format rules.

Last updated