In this report, we want to write a list of orders with some order details (e.g. shipping address, shipping fee, date of the order etc.). We want to arrange these data in Word table form. Data model used for all examples is exposed here.

Initially, we are creating a report template. Follow the common preparation steps to start building the template from scratch:

  • Open a new blank Word document and enable it for templating
  • Turn on Data Sources and Elements Explorers
  • Define default data source as the Order class

After that, you should be at the following point:
Templating tables image

We want to get on the report a list of orders instead of one single order. Thus, the data source should be treated as a collection of items which are typed as Order class. To express this, mark that the default data source of the type Order is going to be used as a collection:
Templating tables image

Insert an ordinary Word table to the template having in mind which properties of an order we want to display. This could look like following:
Templating tables image

Add Docentric List element from the Docentric Ribbon tab (about inserting List elements you can read here) to the template while the whole row of the Word table is comprised:
Templating tables image

Define the Value property of the inserted List element by clicking on the Binding Control:
Templating tables image

On the Binding Control's pop-up, select the default data source (the collection of items of type Order) as a (Binding) Source and leave the (Binding) Path property empty:
Templating tables image

Result looks like this:
Templating tables image

Now, to display particular data of a single order, we have to add Docentric Field elements within just inserted List element bound to the collection of orders. Position yourself in cells of the templated row by Docentric List element and add several Field elements; each of them should be bound to some of the Order property members (about managing Field elements you can read here).
Let's examine how to set binding of a Docentric Field element to the property order date. Click on the Binding Control of the Value property of the element:
Templating tables image
On the pop-up of the Binding Control of the Value property, select the Data Context which is the current data context inherited from the parent Docentric element (the List element) as a (Binding) Source property. Since the List element is bound to the collection of orders, current Data Context refers to an item of the type Order. So, in the other part of the Binding Control's pop-up all property members of the Order class are listed. Choose the OrderDate as a (Binding) Path property:
Templating tables image
The result of the whole procedure of the binding setup for the Field element looks like following:
Templating tables image
In the end, we have also defined a Format String of this Field element as a short date (about formatting values you can read here).


Finally, the templated table (with Design Mode switched on) looks like:
Templating tables image


Next, save the template and generate the report. Report generation takes place programmatically, from your application that is using (has a reference to) the Docentric Report Engine dll. This code looks like following:

// Instancing report engine, by assigning the data source
List<Order> ordersDataSource = DataAccess.GetOrders();
DocumentGenerator dg = new DocumentGenerator(ordersDataSource);

// Generating report by specifying the report template and the resulting report (as file paths)
DocumentGenerationResult result = dg.GenerateDocument("example4.docx", "example4_output.docx");

// Examining potentially errors
if (result.HasErrors)
{
    foreach (Error error in result.Errors) Console.Out.WriteLine(error.Message);
}



Generated report looks like:
Templating tables image