Used to generate report documents by populating report template .docx files with data.

System.Object
  Docentric.Documents.Reporting.DocumentGenerator

Namespace: Docentric.Documents.Reporting
Assembly: Docentric.Documents.Reporting (in Docentric.Documents.Reporting.dll)
public class DocumentGenerator

The DocumentGenerator type exposes the following members.

Name Description
Public constructor .ctor(Object) Initializes a new instance of the DocumentGenerator class.
Name Description
Public member DefaultDataSource Returns the default data source object.
Public member ElementProcessingExclusionRule Gets or sets the rule for excluding the template elements from the generation process. This property is used in combination with the 'FinalizeDocument' property. Content controls of the excluded elements do not get deleted from the document.
Public member FinalizeDocument Get or sets the value indicating weather the generated document should retain its project data. If the property is set to 'True', the generated document will retain its project data and hence considered as a templated which can be processed again. The default value for this proprty is set to 'True'.
Public member NamedDataSources Returns a collection of all named data sources.
Public member WriteErrorsAndWarningsToDocument
Name Description
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object)
Public method GenerateDocument(String, String) Generates an MS Word document by providing the report template file name and the output document file name. The format of the output document will be inferred from the file extension.
Public method GenerateDocument(String, String, SaveOptions) Generates a document by providing the report template file name, the output document file name and the save options.
Public method GenerateDocument(Stream, Stream) Generates a document by providing the report template stream and the output document stream. The output document will be written as an MS Word (docx) document.
Public method GenerateDocument(Stream, Stream, SaveOptions) Generates a document by providing the report template stream, the output document stream and the save options.
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object)
Public method GetType Gets the Type of the current instance. (Inherited from Object)
Public method SetDefaultDataSourceValue Sets the value for the default data source.
Public method SetNamedDataSourceValue Sets the value for the named data source defined by the report template. The name of the data source must be one of the data sources defined in the report template.
Public method ToString Returns a String that represents the current Object. (Inherited from Object)
Name Description
Public event ElementInitialize Occurs when the document generator finds and initializes an instance of an element.
Public event LabelRequest Occurs when a label translation is getting obtained. Use this event to provide a label tarnslation for a given label code and culture.

The GenerateDocument is the main class ToString and represents the Docentric Report Engine itself. To run the document generation call the DocumentGenerator method.

This example shows how to generate a document form a simple template.
IEnumerable<Customer> customers = DataAccess.GetCustomerById(15); DocumentGenerator dg = new DocumentGenerator(customer); dg.SetNamedDataSourceValue("Products", products); DocumentGenerationResult result = dg.GenerateDocument("MyTemplate.docx", "MyReport.docx"); if (result.HasErrors) { foreach (Error error in result.Errors) Console.WriteLine(error); }