In this report, we want to write out some data of one particular order e.g. shipping address, shipping fee, date of the order etc. Order date and shipping fee should be formatted as a short date and a currency, accordingly. 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:
Formatting values image

Add proper Docentric Field elements (about inserting Field elements you can read here) to the template that are bound among other things, to the Orders's properties OrderDate and ShippingFee:
Formatting values 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:

// Getting specific order
Order orderDataSource = DataAccess.GetOrderById(7);

// Instancing report engine, by assigning the data source
DocumentGenerator dg = new DocumentGenerator(orderDataSource);

// Generating report by specifying the report template and the resulting report (as file paths)
dg.GenerateDocument("example2.docx", "example2_output.docx");


It is also possible to invoke the method GenerateDocument with same parameters typed as System.IO.Stream.


Generated report looks like:
Formatting values image

You can notice that the Order date and Shipping fee are not in desired format. In order to change this, set the property Format String of the Field elements bound to OrderDate and ShippingFee properties of the class Order to suitable values, like shown at the picture below:
Formatting values image
You can click on the button next to the Format String control that pops up the assistant form with available format strings for chosen category of data types:
Formatting values image
Or you can type in the Format String control directly valid .NET format string:
Formatting values image
Notice (on the picture above) that in the Element Tree sub pane of the Elements Explorer, all formatted elements have letter "F" assigned.

In the end, generated report will contain OrderDate and ShippingFee properties of the class Order formatted as we wanted in the beginning, as a short date and a currency:
Inserting Field Element image