Creating Templates with the Designer
A datasource excerpt file is used to fill the drop-down lists of the template editor with proper merge fields, relations and dummy data for a template preview. A datasource excerpt file is not your actual data that is used to merge your template. It helps you to design your templates and to insert the proper field names.
Preparing the Data with .NET
In this tutorial, you will learn how to create a new template from a class in .NET. The first part shows how to create a project in .NET where the second part is independent from the used language and shows how to create a template using the template designer.
The accepted JSON format in the document/merge method of ReportingCloud is a JSON string containing an array of objects.
-
If you don't have a ReportingCloud account, create a new account:
-
Open Visual Studio and create a new application (type and language doesn't matter in this tutorial).
-
Start the Package Manager Console from the NuGet Package Manager menu item of the Tools main menu. Type in the following command to install Newtonsoft Json:
PM> Install-Package TXTextControl.ReportingCloud
-
Create the required classes for your report. The following sample shows a simple invoice class:
-
Use the following code to create an instance of your data and use JsonConvert class to serialize the object to a Json string:
Set a breakpoint to line 28 and copy the string from the Text Visualizer to the clipboard:
Adding the Data Excerpt File
This Json format is exactly the format that is accepted by the document/merge method of ReportingCloud and the online template designer.
-
Open a browser and navigate to:
https://portal.reporting.cloud
Log in with your credentials.
-
Click on My Datasource Excerpts and create a new excerpt file by adding a name and pasting the Json string into the Datasource Excerpt text box:
Save the excerpt file by clicking the Excerpt button.
Create the Template
-
Click on My Templates, choose New Template... and type in a name and choose your preferred template format such as DOCX. Confirm with OK.
-
In the next dialog, click on Edit template, choose the created datasource excerpt file from the drop-down box and confirm with Edit Template:
-
The template editor is opened and you can start designing your template. Open the Merge Field drop-down box from the Merge Fields group of the Reports ribbon tab.
Open the master table and insert the merge field invoicenumber.
-
After the merge field has been added, insert some blank lines and then click on Merge Block to select items from the available drop-down items. In the opened dialog box, check description and name and confirm with OK.
-
A repeating merge block (marked as red) is inserted into the template:
-
Now, click on Preview Merge Results in the Preview group and confirm the opened dialog box with OK.
-
Finish your template design, save the template and use Back to navigate back to the dashboard.
This template contains the proper field and block names that matches your datasource. When merging the template with the list of Invoice objects, ReportingCloud will populate the merge fields with the public property values of your invoice objects.