RReport Visual Builder for .NET

Introduction

RReport will assist you in the task of creating reports for your .NET applications. RReport can access a database and retrieve the data to be printed. However this is only one of the possibilities, you can also programatically print the report and set the values yourself, or print data form an array.

The product is made of:

  1. RReport Visual Builder: this is the environment you will use to design the reports.
  2. RReport: this is the runtime library you will use in your .NET application in order to print the report you have previously designed.

Note: the present document covers RReport Visual Builder which uses the RReport library. It is assumed that the reader has some background about the RReport package. Please read also RReport Documentation .

 

 

Distribution of applications

In order to distribute your application that includes reports you must distribute the following file:

You should NOT distribute:

 

Starting the Visual Builder

In order to run the Builder and start designing your reports you need to execute the following commands:

Description of the screen

The screen of the builder is very simple, it has three main parts:

Futhermore the toolbar will allow you to perform this operations (buttons from left to right):

 

screenshot 1

By clicking on the name of the Area its properties will be displayed in the properties window.

 

The properties window

The properties window will display the properties of the selected object, area or report. Click on refresh if you want to see the result of the modified properties.

 

Working with objects

Adding a new object

In order to add a new object you must select the appropiate object in the toolbar and click on the area you want to add the object. Select the first button in the tool bar (the one with the pointer) in order the deactivate the current selection.

Selecting one or more objects

Click on the objects in order to select them. Selected objects show four black squares on the corners. In order to select more than 1 object you must press the SHIFT key and click on the objects.

Deleting objects

Use the CTRL-X or DEL in order to delete selected objects

Moving objects

Move selected objects by dragging and dropping them.

Resizing objects

Move the cursor to the right or the bottom border of the objects in order to resize them. The cursor will the will change and you can drap the border of the object.

Copying objects

Copy selected object with CRTL-C and paste themin the curret area with CRTL-V. You can also use the menu items in the Objects menu or in the popup menu.

Aligning objects

Select the objects you want to align and click on the right button of the mouse. Select then the alignment type from the popup menu.

Bringing object to the front or to the back

you can determine the order in which objects are printed by bringing them to the front or the back. Select the objects you want to move and click on the right button of the mouse. Select then the action (bring to front or send to back) from the popup menu.

 

Description of the supported objects

Report

Select File-> Properties to set the properties of the report. The properties are:

Area

Click on the area's name to set the properties of the area:

RVObject

This object corresponds to the RObject object used in RReport. Its properties are common for all the object used in report. The properties are:

 

RVField

This object corresponds to the RField object used in RReport. It is used to print texts and its properties are:

RVCheck

This object corresponds to the RCheck object used in RReport. It is used to boolean values and its properties are:

RVCombo

This object corresponds to the RCombo object used in RReport. It is used to display values based on the value of a key, its properties are:

RCombo support also a list of images as values to be printed but RVCombo only support a list of strings. If you want to specify a list of images you should do it programatically when you run your report. For example:

[c#]

report.importFile(filename);
RCombo combo=(RCombo) report.getAreaByName(areaname).getItemByName(comboname);
combo.Values=listOfImages;


[vbnet]

report.importFile(filename)
Dim co as RCombo
co= report.getAreaByName(areaname).getItemByName(comboname)
co.Values=listOfImages

See Running the report

 

RVPicture

This object corresponds to the RPicture object used in RReport and is used to print images. Its properties are:

 

RVLine

This object corresponds to the RLine object used in RReport. Its properties are:

 

RVPageBreak

The RPageBreak will force that a page break after the area is printed.

 

RVRectangle

This object corresponds to the RRectangle object used in RReport. Its properties are:

 

RVBarcode

This object will insert a barcode in your report. Note that a separater license of RBarcode is required if you want to print barcodes. RReport includes a evaluation version of RBarcode.

The parameters of the barcode are explained in RBarcode's documentation.

 

RVGraph

This object will insert a chart in your report. Note that a separate license of RChart is required if you want to create charts. RReport includes a evaluation version of RChart.

This object only requires 1 parameter, the "Data File" that contains the chart parameters. This file is created using RChart Visual Builder.

 

Evaluation of expressions

RReport can also evaluate expressions you enter in the "value" property of the RVField objects. Any value starting with "=" is assumed to be an expression to be evaluated unless you set the "evaluate" property of the RVField to "No".

Examples of expressions are:

Supported operators are: + , - , / , \ (integer division), ^ (power), *, % (modulo) and & (concatenation of strings).

Supported functions are:

Supported functions for group footers are:

You can implement your own functions using the IUserFunctions interface and setting the Evaluator.userFunctions property. For example, the following code would implement the "charAt" function that extracts a given character froma string.

 

[c#]

class myFunctions : IUserFunctions {

public object executeFunction(string functionName,object[] parameters) {

// implement charAt function which have 2 parameters: String and position of the char to return
if (functionName.CompareTo("charAt")==0)
if (parameters.GetLength(0)==2) {

string s=parameters[0].ToString();
string positionStr=parameters[1].ToString();
int32 position=Int32.Parse(positionStr);

if (s.Length>position) return ""+s[position];
}

return "";

}

}

Note that user defined functions are only executed within your .NET application. When testing the report inside RReport Visual Builder, user defined functions will be ignored.

 

Using a database

In order to retrieve data from a database you must:

  1. Enter the connection data in the Report's Properties
    1. DB Con Provider: select the provider you want to use (ole is recommended)
    2. DB Con String: enter the connection string
    3. Activate the database connection. Select YES in the DB Active combo box.
  2. Enter the table name or the SQL query in the Area's Properties (see DB Sel Table property). Each area will retrieve data from a table in the database. You can also have nested areas. In this case you must select a "linked Area" (super area) and enter the "link from" (fields in the supertable) and "link to" (fields on the subtable) information in the nested area (subarea). The "link from" and "link to" are list of fields separated by "|" that build the foreign key relationship between tables/areas.
  3. Enter the field name in the Object's properties. The following object support database access: RField, RCheck and RCombo.

 

Running the report

 

The following code will run the report examples/databaseSource/DBorder.rep:

[c#]

using J4L.RReport;
using System;
using System.Drawing;
using System.Windows.Forms;

public class exampleDBOrder:RAreaListener
{

int total=0;


// entry point
public static void Main(string[] args)
{
exampleDBOrder f=new exampleDBOrder();
f.init();
}

public void init() {

// load report from file

Report report=new Report();

if (!report.importReport("examples\\DatabaseSource\\DBorder.rep")) {
Console.WriteLine("Error, exiting");
Application.Exit();
}


// set listener to calculate amounts on the fly
report.getAreaByName("Detail").setListener(this);
report.getReportFooter().setListener(this);


// create preview window
RReportWindow Win= new RReportWindow(report);

// this will print the Header Area and all dependent areas
Console.WriteLine("Preparing report");
report.prepare();
Console.WriteLine("End report");
report.endReport();
Console.WriteLine("Show preview window");
Win.ShowNow();

Application.Exit();
}

public void beforePrintingArea(RArea area) {

// calculate the amount of each line
if (area.getName().CompareTo("Detail")==0) {
double price=((Double) area.getItemByName("Price").getruntimeValue());
int quantity=((Int32) area.getItemByName("Quantity").getruntimeValue());
total=(int) (total+(quantity*price));
area.getItemByName("Amount").setruntimeValue((Int32) quantity*price);
}

// set total amount
if (area.getName().CompareTo("Footer")==0) {
area.getItemByName("Total").setruntimeValue(( (Int32) total));
total=0;
}
}
}

[vbnet]

Imports J4L.RReport
Imports System
Imports System.Data
Imports System.Data.OleDb
Imports System.Drawing
Imports System.Windows.Forms

Module MyModule

Public Class exampleDBOrder : implements RAreaListener

private total as integer

Overridable sub beforePrintingArea(area As RArea) Implements RAreaListener.beforePrintingArea
Dim price as Double
Dim quantity as Integer

' calculate the amount of each line
if (area.getName()="Detail") then
price= area.getItemByName("Price").getruntimeValue()
quantity=area.getItemByName("Quantity").getruntimeValue()
total= (total+(quantity*price))
area.getItemByName("Amount").setruntimeValue( quantity*price)
end if

' set total amount

if (area.getName()="Footer") then
area.getItemByName("Total").setruntimeValue( total)
total=0
end if

end sub

public sub init()

' load report from file
Dim report as Report
Dim dbconnection as OleDbConnection
Dim dbcommand as OleDbCommand

report=new Report()


if (not report.importReport("examples\DatabaseSource\DBorder.rep")) then
Console.WriteLine("Error, exiting")
end
end if


' set the images for the combo box. This can only be done programatically
Dim comboImages(3) as Image
comboImages(0)=new RImageFile("images/ball1.gif").getImage()
comboImages(1)=new RImageFile("images/ball2.gif").getImage()
comboImages(2)=new RImageFile("images/ball3.gif").getImage()
Dim co as RCombo
co= report.getAreaByName("Detail").getItemByName("Priority")
co.Values=comboImages

' set listener to calculate amounts on the fly
report.getAreaByName("Detail").setListener(me)
report.getReportFooter().setListener(me)

' create preview window
Dim Win as RReportWindow
Win= new RReportWindow(report)

' this will print the Header Area and all dependent areas
report.prepare()
report.endReport()
Win.ShowNow()

End

end sub

end class
end module


The process is:

  1. The report is created by calling the constructor new Report().
  2. load the report using importReport(file). This will also open the database (this example uses a Ole data source that opens the database RReport2.mdb). Here you will find other examples that do not use database.
  3. sets the area listeners. This will be triggered for each repetition of detail and page footer.
  4. create a preview window if you need it.
  5. call prepare(). This will print the report header. The detail area will also be printed since it is a subarea of report header.
  6. call endReport().

Accesing loaded fields and methods:

In order to change the properties of object or area after loading a report from a file you must use the methods:

[c# / vbnet]

rreport.getAreaByName() and rarea.geItemByName().

for example. In order to change the image of a RPicture object you must call:

[c# / vbnet]

report.getAreaByName("areaname").getItemByName("RPicturename").setruntimeValue(Image)

note that if your want to access the headers, background or footers area you must use the rreport.getPageHeader(), rreport.getReportHeadert()...

Using your own database connection and statement for database access:

If your report uses a database, it will open the database connection when you execute the importReport() method. If you already have a database connection you can use your own IDBConnection object in this way:

[c#]

dbconnection=new OleDbConnection();
dbconnection.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=RReport2bis.mdb";
dbconnection.Open() ;
report.setDBCon(dbConnection);

report.importReport("filename");

[vbnet]

Dim dbconnection as OleDbConnection
dbconnection=new OleDbConnection()
dbconnection.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=RReport2bis.mdb"
dbconnection.Open()
report.setDbCon(dbconnection)

report.importReport("filename")

The importReport() method will also create all necesary RAreas and RDatabaseSource objects. The RDatabase Source's constructor needs a ICommand object as parameter.

If you want to change the sql statement at runtime:

[c#]

((RDatabaseSource) report.getAreaByName(name).getDataSource()).setSQL("Select * from Employees");

[vbnet]

Dim ds as RDatabaseSource
ds=report.getAreaByName(name).getDataSource()
ds.setSQL("select * from PurchaseOrderBis")

 

Programatically printing

If you do not use any RSource you must print the imported report programatically ba setting the values of the object in the area one by one and printing every single repetition with rreport.printArea(). Like this:

[c#]

report.importReport(name);
myArea=report.getAreaByName(areaname);

while (datatoprint) {
// set values for fields
myArea.getItemByName(fieldname1).setruntimeValue(value1);
myArea.getItemByName(fieldname2).setruntimeValue(value2);
.....

// print repetition
report.printArea(myArea);
}

[vbnet


while dataToPrint
'set values for fields
myArea.getItemByName(fieldname1).setruntimeValue(value1)
myArea.getItemByName(fieldname2).setruntimeValue(value2)
.....
' print repetition
report.printArea(myArea)

while end

Using other RSources

In other to use other RSources (for example, printing an array) ,different from RDatabaseSource, you must import the report and set the new RSource:


[c#]

report.importReport(name);
report.getAreaByName(areaname).setDataSource(yourRSource);

 

Combining RSources and programatically printing

If you use a RSource object to print all repetitions of an area automatically but you still need to set a field value programatically your must use a RareaListener.