For examples in this section the data model below is used.
Each of examples demonstrates step by step designing of one Docentric report template and later, generating the report based on it, putting emphasis on specific Docentric feature.

Data Model Class Diagram ;


Each of examples, because of simplicity, uses following code to generate report based on a template:

// Instancing report engine, by assigning the data source
DocumentGenerator dg = new DocumentGenerator(DataAccess.GetOrderById(7));
// Generating report by specifying the report template and the resulting report (as file paths)
dg.GenerateDocument("example.docx", "example_output.docx");

Certainly, it is not necessary to read template from the file system and write generated report to the file system; more often you would want to perform generation by using these parameters (both the template and the output generated document) typed as System.IO.Stream. For example, your code could look like the following:

using (FileStream templateStream = new FileStream("example.docx", FileMode.Open))
{
     DocumentGenerator dg = new DocumentGenerator(DataAccess.GetOrderById(7));
     MemoryStream outputDocumentStream = new MemoryStream();
     dg.GenerateDocument(templateStream, outputDocumentStream);
     ...
}

This scenario is handy if, for example, the templates are stored in a database; then you can read them into Stream. Generated report in a form of Stream can be useful, for example, for instantly showing them in front of the user and later, for saving to a document storage (database, document systems etc.).