Support

Lorem ipsum dolor sit amet:

24h / 365days

We offer support for our customers

Mon - Fri 8:00am - 5:00pm (GMT +1)

Get in touch

Cybersteel Inc.
376-293 City Road, Suite 600
San Francisco, CA 94102

Have any questions?
+44 1234 567 890

Drop us a line
info@yourdomain.com

About us

Lorem ipsum dolor sit amet, consectetuer adipiscing elit.

Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec.

Chapter 6 Dynamic lists

6. Dynamic Lists

The dynamic list is the tool of choice in ReportServer when it comes to fast, user-specific evaluations or when the focus is on the subsequent further processing of the data.

From the simple selection of data using column selection and filters, to sorting, grouping or subtotals, through to complex analytical functions, the dynamic list can be used to map almost any evaluation requirement.

Once configured, evaluations can be saved as a variant in TeamSpace and shared with colleagues.

If you have opened a dynamic list for execution, you are then in the report area, where you can configure and finally execute the evaluation.

The basis of every dynamic list is a source table provided by an administrator. This is usually very extensive and can easily consist of hundreds of columns and several million rows. In order to extract information from this data, it is necessary to select the data to be viewed. For this purpose, ReportServer offers a variety of different tools with which even complex selection conditions can be formulated intuitively.

6.1 Selecting columns

The first step in creating a new dynamic list is to select the columns to be used. You can access the column selection via the toolbar of the List configuration aspect. This opens the familiar selection dialog (see chapter First steps). All available columns are offered for selection in the dialog box.

The selected columns are transferred to the List configuration aspect.

The following information is displayed for each selected column:

Column The technical name of the column.
Default column name A possibly pre-assigned plain text name.
Column name Here you can assign your own name/alias for the column.
Description Contains an explanation of the meaning of the column, if available.
Options Indicates the configuration made using symbols.
Aggregation Allows aggregation on this column see section Aggregation.
Sorting Allows the data to be sorted by this column.
Hidden The column can be hidden using the Hidden option.
Type Specifies the underlying data type.

6.2 Data types

Each column in a database is assigned a fixed data type, which determines the type of content possible in this column. There are different data types, e.g. for texts, numbers and dates. Common data types are

VARCHAR Text with fixed maximum length
INTEGER A whole number
DOUBLE/FLOAT A floating point number
DECIMAL A decimal number
CLOB/BLOB Text of any length / binary data
DATE A date possibly incl. time

The order of the columns in the finished report corresponds to the order of the columns in the list configuration. The order can be set using drag-and-drop or via the context menu.

To call up the data returned by the report in the current configuration, switch to the Preview aspect. The first 50 lines of the list you have configured are displayed in the preview. Information on the selected data is displayed in the preview toolbar (at the bottom). In addition to the total number of available data records, this includes information on the column selection and runtime. The runtime information is divided into the pure server time and the duration of the entire request. The Forward and Back buttons can be used to scroll through the results.

Double-click on a row to open the selected data record in a new window for a detailed view. To quickly adjust the configuration, you can also access many functions of the List configuration aspect via the context menu of a data cell.

6.3 Alias, sorting and hidden columns

To change the name of a column, you can assign an alias in the list configuration. To do this, click in the corresponding cell under Column name and assign a new name.

Depending on the configuration, a suggested name may be stored for a column. This is displayed in the Default column name column, if available. If you have set your own column name, this will overwrite the default.

You can set the sorting of the data records in the finished report under Sorting for each column. If several columns are configured for sorting, the priority of the sorting follows the order of the columns.

In the Hidden column, you can exclude individual columns from the display. This is useful if you want to use a column for filtering or sorting but do not want it to be included in the display.

6.4 Filter

Filters allow you to restrict the data in the report at row level by defining inclusion and exclusion criteria for each column. This section covers the basics of the filter function. Further options, such as filtering with placeholders or formula expressions, are presented later in this chapter. To define a filter condition for a column, select it in the List configuration aspect and open the filter dialog by double-clicking or using the corresponding button in the toolbar.

You have two basic options for selecting the data records to be included, based on the population.

1. Selection of the subset to be included: This data is included in the finished report (inclusion)
2. Selection of the subset to be ignored: All data, except the selected data, is included in the finished report (exclusion)

If you have defined both inclusion and exclusion, the exclusion is no longer based on the population, but on the data records selected for inclusion. This means in particular: If you have explicitly included and excluded a single value, it is not included in the result set.

The filter dialog offers the option of defining inclusion and exclusion on the basis of both individual values and value ranges. Use the corresponding tabs for this purpose.

The structure of the individual tabs is basically the same and is similar to the familiar selection dialog. On the left-hand side, you will find the column values based on the currently configured population, which may already be restricted by other filters (both on the current column and on other columns).

Here too, values are transferred to the selection by double-clicking or drag-and-drop. To include or exclude ranges, two consecutive selections are combined into one range (from A to B).

 

As an alternative to selecting values, they can also be entered directly by switching the view from Grid to Text or inserted from the clipboard (Copy & Paste).

Ranges are entered in text mode as "A - B". Note the spaces before and after the minus sign. You can define an open interval by omitting one of the range limits. The range definition "All values greater than 5" would be written as "5 - ".

To load all values occurring in the column, regardless of already configured restrictions, click on the chain symbol (force consistency) next to the search field. (Normally you will not need this function). It allows you to define filters that would produce an empty result with the current data basis, but may still be useful if the initial data has changed.

By default, filtering is case-sensitive, i.e. the value occurring in the data must be written exactly as your filter expression. If desired, you can switch this off using the case-sensitive option. Please note that ignoring upper/lower case can have a negative impact on performance.

6.4.1 Empty cells (NULL)

A special feature of databases that you should be aware of when filtering is the treatment of empty cells. By an empty cell, we mean a cell in which there is no value (in database jargon, it has the value NULL). NULL is particularly different from an empty string "" or the number 0.

Due to this peculiarity that NULL is different from any value, all cells with the value NULL are excluded as soon as you have defined any filter. This may seem counter-intuitive, especially if only one exclusion filter is defined, but it is common in relational algebra, which forms the basis of all common database systems, and is therefore also implemented in ReportServer.

For you, this means that if you have defined filters on a column and you also want empty cells to be included in the result set, you must explicitly include the empty cells. Conversely, the explicit exclusion of empty cells is only necessary if you have not defined any other filters for this column. You control the handling of empty cells via the drop-down box of the same name in the filter dialog.

6.4.2 Filtering for floating point numbers (Float/Double)

Please note that due to the definition of floating point numbers, checking for equality is only possible to a limited extent. When filtering for columns of type float or double, you should therefore only use range filters if possible. Instead of including the value 5.1, use a range filter 5.0009 - 5.1001, for example.

6.4.3 Distinct: Remove duplicate lines from output set

Use the Remove duplicate rows in output set option in the List configuration aspect to suppress the display of duplicate data records in the result set. A row is considered duplicate if it is identical to another row in all visible columns.

6.5. Format

ReportServer allows you to set the desired output format for each column directly in the list configuration. To do this, select the desired column or columns and select the Column format button.

You can set the column format to be used in the dialog box that opens.

Depending on the data type of the column, the following formatting options are available:

Number The value is interpreted as a number and output with the set number of decimal places. Optionally, a 1000 separator can be configured.
Percent The value of the cell is interpreted as a percentage.
Scientific Numbers may be output in exponential notation.
Currency The value is interpreted as a number and extended by the selected currency symbol.
Date The value is interpreted as a date and output in the specified target format. If the type of the underlying column is not a date type, the base format in which the values are available in the database must also be specified. In this case, the two options Clean up invalid data and Replace incorrect data can be used to set the handling of values in the database that do not represent a correct date. For example, 35.03.2012 or "Last Tuesday". Clean up invalid data calculates in the first case the effective date as 04.04.2012 in the second case no cleanup is possible. In this situation, an alternative value can be specified using Replace incorrect data. A ${} formula expression (see chapter Formula language) can also be specified here, with the replacement "value" for the actual value. The definition of the target and base format can be found in the Date format table in Appendix C.
Text The value is interpreted as text - for example, leading zeros are retained.
Template
Allows the specification of a ${} formula expression that controls the formatting (see chapter Formula language. The replacement "value" contains the existing value.

6.6 Report documentation

Use the Show report documentation button to open the report documentation. This almost clearly summarizes all the settings made. Please note that the report documentation always refers to the last saved version of the variant. The illustration shows an example of report documentation. For more information on report documentation, please also read the section Report documentation.

6.7. Filtering with placeholders (*, ?)

In the filter dialog in text input mode, you can work with wildcards in addition to entering an exact value.

The placeholder * represents a character string of any length. This also includes the empty character string. Example: Roof* includes both attic, roof truss and roof alone.

The wildcard ?, on the other hand, denotes exactly one character.

Wildcards can also be used in the search mask of the filter dialog.

For wildcards in range filters, the largest possible range is selected. If the mask described by the wildcard matches several values, the smallest matching value is selected for the lower interval limit and the largest matching value is selected for the upper limit.

Please note that if there is no value corresponding to the pattern for one of the interval limits, the interval is empty. This can lead to unexpected problems, particularly with inclusion, e.g. a* - z* is empty if there is no value starting with z.

6.8. Aggregation

Aggregation refers to the combining or summarizing of data that is identical with regard to a grouping characteristic and thus forms a group. The result set contains one data record for each group present in the source data.
As an example, let's look at a list of people with the characteristics of gender and age. A possible aggregation would now be the average age grouped by gender. Here, a list with n data records is summarized to a result with one row per gender.
In aggregation, we therefore distinguish between attributes that determine which group a data record belongs to (gender) and those that are summarized into a single value using an aggregate function.

The aggregate functions implemented in ReportServer are

average Calculates the average value for an attribute.
Counting Specifies the number of data records per group.
Maximum Specifies the maximum value of the group.
Minimum Specifies the minimum value of the group.
Sum Calculates the sum of all values in the group.
Variance This function calculates the variance.
Various counting Like counting, but only considers different values of the attribute.

Ist in ReportServer für eine Spalte eine Aggregatsfunktion eingestellt, so werden automatisch alle Spalten, ohne Aggregation, als Gruppierungsmerkmal betrachtet. Es ist nicht möglich, dass eine Liste Spalten enthält die weder Teil der Aggregation, noch der Gruppierung sind.

Um Aggregationen in Auswertungen zu nutzen, legen Sie im Aspekt Listenkonfiguration für einzelne Spalten/Attribute die zu verwendende Aggregatsfunktion fest.

6.8.1 Partial results

To additionally display the underlying individual data records for each group when using the Aggregation function, use the Partial results function from the list configuration toolbar. In the dialog box that opens, select the columns to be used for grouping from the non-aggregated columns. All non-selected and non-aggregated attributes are displayed in the individual data records.

6.8.2 Filter and aggregation

Filters in the List configuration aspect always work on the visible end result. In conjunction with the Aggregation function, this means that the data is first aggregated and then filtered on the result. In our example with the average age, this means that a filter on the Age column filters the average age in the result, but is not suitable for excluding individual data records from the averaging.

A filter on the "Age" column with the definition "30 - " therefore does not change the average value of the two groups, but causes only groups with an average value greater than or equal to 30 to be displayed. If you are familiar with the SQL database language, you can remember that filters on aggregated columns are implemented as HAVING filters.

To filter the data records included in the aggregation rather than the result of the aggregation as described here, you can use the Prefilter function described below.

6.8.3 Pre-filter

Pre-filters are a powerful tool for limiting the database of an evaluation. Their possible uses go far beyond the filters in the list configuration aspect. The three main differences are

While all filters in the column configuration are AND-linked, i.e. a data set is included in the result set if it fulfills the filter conditions of all columns, any combination of AND and OR expressions can be defined in the pre-filter to link the filter conditions of different columns.

Column comparison The column comparison allows you to define a filter criterion based on the relationship between two attributes of a data record. For example, all data records in which the value in column A is different from the value in column B could be selected.

Filtering before aggregation As described in the previous section, the list configuration filters always affect the visible result. In combination with the aggregation, this means that filters only take effect after the aggregation. Pre-filters, on the other hand, always take effect before aggregation. If no aggregation is configured, there is no difference in this respect between pre-filters and the filters of the list configuration.

6.8.4 Structure of pre-filter expressions

The pre-filter contains a set of filter expressions which can be combined with AND and OR and nested as required.

Let's look at an example with the following four filters
A := age > 30
B := Gender == female
C := Place of residence == Berlin
D := age < 5
E := place of birth == place of residence

The combination of these individual filters to the following combined expression

(B UND C UND (A ODER D ODER E))

now describes the selection of all women from Berlin who are either younger than 5 or older than 30 years.

 

ReportServer's prefilter displays such an expression as a tree, as follows:

AND B
C
OR A
D
E
 

AND and OR represent blocks that enclose the underlying expressions. The AND block in the example therefore contains B, C and the OR block. The OR block in turn contains A as well as D and E.

When evaluating the tree, the individual filters (A, B, C, D, E) are first evaluated for each data set. The result of each such evaluation provides a truth value: TRUE or FALSE.

Example data set:
Age = 25
Gender = Female
Place of residence = Berlin
Place of birth = Stuttgart

If the filter conditions A to E mentioned at the beginning are evaluated against this example data set, the following tree is obtained:

 
AND TRUE
TRUE
OR FALSE
FALSE
FALSE

In the following step, the truth values of blocks are determined. To do this, the truth values of all blocks that do not contain any other blocks are combined with the logical operation of the block.

An AND block is TRUE if all enclosed expressions are TRUE. An OR block is TRUE if at least one of the enclosed expressions is TRUE.

The block is then replaced by its truth value. This process is repeated until the root block is determined.

In the example, this is done in two steps:

AND TRUE
TRUE
FALSE

 

FALSE

This means that the sample data set is not part of the result set.

Use the toolbar to add blocks and filters to your expression. These are inserted below (as part of) the currently selected block. Blocks and filters can be moved to another block using drag-and-drop. The order of expressions within a block is irrelevant. AND blocks can only contain OR blocks directly and OR blocks can only contain AND blocks. When inserting new blocks or moving them, the correct type is automatically selected.

Note that the complete pre-filter tree can be exported to a DOT file with the "Export to DOT" button (renderable via any Graphviz tool, incl. ReportServer REST dot-renderer) or to the Excel export with the output_filters or output_complete_configuration report properties. Further information can be found in the administration manual.

6.9 Calculations in filters

The $ formula language already mentioned several times can also be used in the filter dialog. Instead of a value, you can enter any formula in text mode. In addition to the standard replacements (see Formula language), the following additional objects/replacements are available in the formulas in the filter for your own calculations:

today A calendar object that can be used to perform calculations based on the current date. For example, a range filter that finds all invoices from the last 7 days.
agg Provides access to calculations for all values in the current column. This can be used, for example, to identify outliers.
analytical Allows access to analytical functions. For example, a filter can be defined that includes the top 10%.

6.9.1 Using the today object

The today object provides access to a complete calendar. This calendar is initialized with the current date and time of execution. You can use the following functions to manipulate the date and time stored in the calendar.

firstDay Sets the calendar to midnight (0 o'clock) of the first day of the current month.
lastDay Sets the calendar to the last second of the last day of the current month.
addDays Moves the calendar forward/back the specified number of days.
addMonths Moves the calendar forward/back the specified number of months.
addYears Sets the calendar forward/backward by the specified number of years.
setDay Sets the calendar to the specified day.
setMonth Sets the calendar to the specified month.
setYear Sets the calendar to the specified year.
clearTime Resets the time to midnight.
addHours Sets the calendar forward/backward the specified number of hours.
addMinutes Sets the calendar forward/backward by the specified number of minutes.
addSeconds Sets the calendar forward/backward by the specified number of seconds.
setHours Sets the time to the specified hour.
setMinutes Sets the time to the specified minutes.
setSeconds Sets the time to the specified seconds.
format This function converts the date into a text in the specified format. This is necessary in order to make comparisons on columns that are not of the date type (see table Date format in Appendix C.).

Example: You want to filter all invoices from the previous month. To do this, you can define the following inclusion filter:

${today.firstDay().addMonths(-1)} - ${today.firstDay().addSeconds(-1)}

If the column is of type VARCHAR (i.e. a text column) and the format is specified in the form day.month.year, you must extend the formula expressions by calling the format function:

1. ${today.firstDay().addMonths(-1).format("dd.MM.yyyy")}
2. -
3. ${today.firstDay().addSeconds(-1).format("dd.MM.yyyy")}

6.9.2 Using the agg object

The agg object provides access to calculations for all values in the current column. For example, a filter expression that refers to the average value of the column can be defined.

The following functions are available:

avg This function calculates the average.
count This function counts the existing values.
countDistinct This function counts the existing different characteristics.
sum This function adds up all the values in the column.
variance This function calculates the variance of the column.
max This function determines the maximum value of the column.
min This function determines the minimum value of the column.
The formula !{agg.avg()+10}! describes an interval of width 20 around the mean value. You can use this expression as a range filter to find values that deviate unusually strongly from the average value, for example.
There must be no spaces between the subtraction and the function if you are subtracting in a range filter. Otherwise, the subtraction character is interpreted as a range separator.
The aggregate functions require a complete scan of the data. If there is a very large amount of data in the report, this may take a little longer.

6.9.3 Using the analytical object

Similar to the agg object, the analytical object allows you to define filters for a column based on a calculation of all values in the column. In contrast to the agg object, which only ever returns a single value, the analytical object returns a set of values. The analytical object can therefore only be used in values, but not in range filters.

The following functions are provided by the analytical object:

top(n) Returns the largest n values in the column.
bottom(n) Returns the smallest n values of the column.
topGrouped (n,'Column name') Returns the largest n values of the column, grouped according to the column name.
bottomGrouped (n,'Column name') Returns the smallest n values of the column, grouped according to the column column name.

If an integer is specified for n, the specification is interpreted as the number of values to be returned. A decimal number in the range 0 to 1 is interpreted as a percentage. For example, top(0.1) denotes the top 10%.

With the two grouped functions, you must also specify the name of a column. The report is first grouped according to this column. The top or bottom values are then determined.

Imagine a report on the customer table with the two columns Y_VOLUME (the customer's turnover) and CUS_COUNTRY (the customer's country of origin). We want to create a list containing the top 5 customers per country, for all countries. For this purpose, we define a filter in the Y_VOLUME column with the following expression: ${analytical.topGrouped(5,'CUS_COUNTRY')}. If this expression is evaluated at runtime, it returns the turnover values of the top customers per country. The filter on the turnover column therefore includes all customers who have an identical turnover to one of the top customers.

The analytics functions require a complete scan of the data. If there is a very large amount of data in the report, this may take a little longer.

6.10. Calculated fields

Calculated fields allow you to add columns to your analysis that do not appear in the source data, but result from a calculation rule from the existing columns.

The calculation rule is specified in the form of an SQL expression that is executed directly on the database. This means in particular that the available expressions depend on the database used. You can find out which functions are available in detail from your administrator. This section only explains some general options.

If you have defined a calculated field in ReportServer, you can then use this just like any other column in your evaluations. You must also add calculated fields in the List configuration aspect of your report in order for them to be displayed in the results.

When defining calculated fields, you cannot access the values of other calculated fields.

Calculated fields are configured in the Calculated fields aspect. Here you can create fields and edit their definition. The name you assign serves as the name for the column created and must therefore comply with the specifications for column names (alphanumeric, no spaces). Column names must be unique.

SQL offers a multitude of possibilities to define a field, which clearly exceed the scope of this manual. Nevertheless, here are some code examples that are frequently used in calculated fields.

In the following we assume a table with the following columns
A, B: Columns with text
C, D: Columns with whole numbers

For simple calculations, you can use the basic arithmetic operations, e.g.
C + D as the definition for a field with the sum of both columns.

Concatenation, the joining of two text columns, is usually done with the || operator. The + operator or the call of CONCAT(A, B) are also common.

CASE expressions can be used to formulate conditions. For example, values can be classified depending on their size.

CASE
	WHEN SPALTE < 500 THEN 1
	WHEN SPALTE < 1000 THEN 2
	WHEN SPALTE < 2000 THEN 3
	WHEN SPALTE < 3000 THEN 4
	ELSE 0
END

With CASE expressions, please note that the statement of the first applicable condition is selected regardless of whether a subsequent condition may also apply. The return values of all conditions must be of the same data type.

6.11. Templates

In addition to the familiar export formats such as EXCEL or CSV, dynamic lists can also be inserted directly into predefined templates. In this section, we present the basic functionality.

Templates are managed via the Edit template button when executing a dynamic list in the List configuration aspect. In the dialog that opens, you will see a list of the templates that currently exist for this variant. You can use the toolbar to add new templates or download existing ones for editing.

In addition to a name and description, templates also have a type. The following types are currently available:

jXLS Allows the definition of templates in Microsoft Excel.
XDoc Allows the definition of templates in Microsoft Word.
Velocity Allows the definition of text templates.
XSLT Allows the definition of XML templates.

If you have created a new template, you can then upload the corresponding file. In the following, we provide an example for each template type. However, a complete documentation of the functionality would go beyond the scope of this manual. Further documentation on the individual template formats can be found at:

6.12. Excel templates with JXLS

By integrating the JXLS Template Engine into ReportServer, it is also possible to create sophisticatedly formatted Excel worksheets directly from the reporting platform. The JXLS approach is that the template, which determines the appearance of the actual document, is itself an Excel worksheet and can therefore be created and edited directly with Microsoft Excel. Special instructions in the template document control where data is inserted in the template.

Examples of JXLS in ReportServer can be found here: https://github.com/infofabrik/reportserver-samples/tree/main/src/net/datenwerke/rs/samples/templates/jxls.

A detailed description of all the functions of JXLS would go beyond the scope of this document, so here is just a brief explanation of the basics. JXLS2 is supported in ReportServer and is briefly described here. The legacy JXLS1 version is not supported.

6.12.1 Excel templates with JXLS2

You can find complete JXLS2 documentation on the JXLS project page at http://jxls.sourceforge.net. Here we provide an overview of the most important components for working with ReportServer.

Note that you can export dynamic lists as JXLS templates from ReportServer 3.4.0 onwards. This functionality can help you with the manual creation of JXLS templates, as manual creation can be cumbersome in some cases. Many thanks to Karolina Boboli for sending us this script and allowing us to use it.

In JXLS2 (http://jxls.sourceforge.net), you define the JXLS2 commands using Excel comments. The JXLS2 engine analyzes these comments and transforms the template accordingly. Here we show you a simple example of a template and briefly explain its components. Further information can be found in the administration manual (JXLS reports) and in the JXLS2 documentation.

Consider the following example:

Cell A1 contains an Excel comment with the following text: jx: area (lastCell = "B1"). It defines the boundaries of our template as A1:B1. It also contains a Jxls Each command with the following text: jx: each (items = "data" var = "customer" lastCell = "B1"). The Each command iterates the collection of objects in the ''data'' variable and prints the corresponding information. The main range of the Each command is A1:B1 (defined by the lastCell attribute). This means that the cells are cloned and processed with each new customer object in the context.

Note that ''data'' contains the data selected by the dynamic list. This is automatically provided by ReportServer and can be used directly in JXLS templates when used as a template for the dynamic list.

jx:area(lastCell="B1")
jx:each(items="data" var="customer" lastCell="B1")

${customer.cus_customername} | ${customer.cus_phone}

Please note that you must enter the fields in lower case so that they are correctly assigned by the JXLS engine.

6.13. JXLS template example

Now that we have learned how templates generally work as templates in ReportServer, let's look at an example.

In order to get a practical feel for the use of templates in ReportServer, we will now illustrate a practical example of templates with JXLS.

6.13.1 Creating a dynamic list

First, we create a dynamic list and select the columns that we want to return via the template in template-defined form. In this example, we start from the sample report ''T_AGG_EMPLOYEE'' and select the columns ''EMP_EMAIL'', ''EMP_EMPLOYEENUMBER'', ''EMP_FIRSTNAME'', ''EMP_JOBTITLE'', ''EMP_LASTNAME'', ''EMP_OFFICECODE'', ''OFF_CITY'', ''OFF_COUNTRY'' and ''Y_SALES_AMOUNT''.

Here we can see a preview of all the columns with your data that we consider important for each data record.

Now we need to create the template. This is best done with Excel and can be done using an official example like this: http://jxls.sourceforge.net/reference/each_command.html. In relation to our example, you could download the templates here: https://github.com/infofabrik/reportserver-samples/tree/main/src/net/datenwerke/rs/samples/templates/jxls/jxlsdynamiclist.

This is roughly what the template looks like in an Excel file.

Now all that remains is to load the template onto the ReportServer. To do this, follow these instructions in exactly the order described:

  1. Please click on Configure list
  2. Click on the Edit template button
  3. Then click on Add template
  4. Enter the format as JXLS format in the Template Type pull-down menu
  5. Now just upload the previous excel file

Now the dynamic list should enable a new export format called template. Thanks to the previous example template, the Excel file should generate the following output.

6.14. Text templates with velocity

Velocity https://velocity.apache.org/ is a template language for text documents. You can use it to create any output format that uses plain ASCII text as the file format.

You can find Velocity examples in ReportServer here: https://github.com/infofabrik/reportserver-samples/tree/main/src/net/datenwerke/rs/samples/templates/velocity.

Hallo Welt, dies ist eine Velocity Template!

The replacement $data can be used to access the individual data records (the example assumes that the dynamic list contains the field "CUS_CUSTOMER_NAME").

Customer list:

Customer List:
----------------------------------------------------------
#foreach ( $customer in $data )
	$customer.CUS_CUSTOMERNAME
#end

This template can also be downloaded from our reportserver-samples GitHub: https://github.com/infofabrik/reportserver-samples/tree/main/src/net/datenwerke/rs/samples/templates/velocity

6.14.1 Parameter access

You can use/display your report parameter values by using the available ''parameters'' object. For example, if your report has a parameter ''myparameter'', you can access it with the following:

$parameters.myparameter

You can also access all the special parameters explained here: https://reportserver.net/en/guides/admin/chapters/using-parameters/ by using the available ''meta'' object. The following example shows the name of the report:

$meta._RS_REPORT_NAME.value

Note that, unlike the report parameters explained above, ''value'' is required to retrieve the values of the special parameters.

6.15. Word templates with XDocReport

XDocReport https://github.com/opensagres/xdocreport brings the Velocity template language together with Microsoft Word.

You can find XDocReport examples in ReportServer here: https://github.com/infofabrik/reportserver-samples/tree/main/src/net/datenwerke/rs/samples/templates/xdoc.

To use template commands, such as

#foreach ( $customer in $data )

you must embed them in so-called MergeFields. To do this, go to "Insert/Quick blocks/Field..." and then select the MergeField field from the Mail merge category. The command is then entered in the input field under Field functions. For example, the above velocity example could be mapped as follows, where MERGEFELD[XX] stands for a command as a merge field.

Alle Kunden:
MERGEFIELD[#foreach($customer in $data)]
MERGEFIELD[$customer.CUS_CUSTOMERNAME]
MERGEFIELD[#end]

In the following screenshot you can see the resulting template in Word. This and the results of the template execution can also be downloaded from our reportserver-samples GitHub: https://github.com/infofabrik/reportserver-samples/tree/main/src/net/datenwerke/rs/samples/templates/xdoc

6.15.1. Parameter Zugriff

You can use/display your report parameter values by using the available ''parameters'' object. For example, if your report has a parameter ''myparameter'', you can access it with the following:

MERGEFIELD[$parameters.myparameter]

You can also access all the special parameters explained here: https://reportserver.net/en/guides/admin/chapters/using-parameters/ by using the available ''meta'' object. The following example shows the name of the report:

MERGEFIELD[$meta._RS_REPORT_NAME.value]

Note that, unlike the report parameters explained above, ''value'' is required to retrieve the values of the special parameters.

6.16. XML templates with XSLT

To create XML based on dynamic lists, you can use XSLT (Extensible Stylesheet Language Transformations).

The input data for the XSL transformation is the HTML export from ReportServer. Below is a simple generic transformation that converts the data into a simple XML format by first enumerating all attributes and then inserting a "record" element for each data record:

This example can be found here: https://github.com/infofabrik/reportserver-samples/blob/main/src/net/datenwerke/rs/samples/templates/xslt/.

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="http://www.w3.org/1999/xhtml">

<xsl:template match="/">
    <myXmlFormat>
		<xsl:apply-templates select="//xhtml:tr"/>
	</myXmlFormat>
</xsl:template>

<!-- attributes -->
<xsl:template match="xhtml:thead/xhtml:tr">
	<attributes>
	<xsl:apply-templates mode="attributes" />
	</attributes>
</xsl:template>
<xsl:template match="xhtml:th" mode="attributes">
	<attribute>
		<xsl:value-of select="."/>
	</attribute>
</xsl:template>

<!-- values -->
<xsl:template match="xhtml:tbody/xhtml:tr">
    <records>
	<xsl:apply-templates mode="values" />
	</records>
</xsl:template>
<xsl:template match="xhtml:td" mode="values">
	<record>
		<xsl:value-of select="."/>
	</record>
</xsl:template>

</xsl:stylesheet>

The result could then look like this, for example:

<?xml version="1.0" encoding="UTF-8"?>
<myXmlFormat
	xmlns:xhtml="http://www.w3.org/1999/xhtml">
	<attributes>
		<attribute>Country</attribute>
		<attribute>City</attribute>
		<attribute>Office Code</attribute>
		<attribute>Firstname</attribute>
		<attribute>Lastname</attribute>
		<attribute>Employee Nr</attribute>
		<attribute>Jobtitle</attribute>
		<attribute>Email</attribute>
		<attribute>Amount</attribute>
	</attributes>
	<records>
		<record>USA</record>
		<record>San Francisco</record>
		<record>1</record>
		<record>Leslie</record>
		<record>Jennings</record>
		<record>1165</record>
		<record>Sales Rep</record>
		<record>ljennings@classicmodelcars.com</record>
		<record>1.081.530,54</record>
	</records>
	<records>
		<record>USA</record>
		<record>NYC</record>
		<record>3</record>
		<record>George</record>
		<record>Vanauf</record>
		<record>1323</record>
		<record>Sales Rep</record>
		<record>gvanauf@classicmodelcars.com</record>
		<record>669.377,05</record>
	</records>
</myXmlFormat>
Copyright 2007 - 2024 InfoFabrik GmbH. All Rights Reserved.

We use cookies and other technologies on our website. While some of these are essential, others are used to improve the website and evaluate the success of our campaigns. When you use our website, data is processed to measure adverts and content. Further information can be found in our privacy policy. You have the option to adjust or revoke your settings at any time.

Datenschutzerklärung Impressum
You are using an outdated browser. The website may not be displayed correctly. Close