Creating invoices is one of the most typical applications for TX Text Control and ReportingCloud. Using MS Word compatible word processing documents as templates is one of the major advantages of the flow type layout reporting concept over other reporting tools.

The difference between Flow Type Layout Reporting and traditional reporting engines is that a template doesn't consist of various reporting items, but floating text. Word processing rules define how a table is wrapped to the next page or when a table header should be inserted. You can keep lines together, control widow and orphans and add forced page breaks to specific paragraphs.

First, let's have a look at the JSON data source that is used to create the invoice:

[
{
"invoice" : {
"number" : "R2019041151",
"date" : "4/15/2019",
"duedate" : "5/15/2019",
"discount" : 15,
"tax": 7.5
},
"company" : {
"name" : "Text Control, LLC",
"street" : "6676 Text Control Rd",
"address" : "28210 Charlotte, NC",
"country" : "United States"
},
"payer" : {
"companyname" : "Payer Corporation",
"name" : "Peter Jackson",
"street" : "2212 Payer Dr",
"address" : "28210 PayCity, NC",
"country" : "United States"
},
"payment" : {
"routing" : "7783478",
"account" : "877874627654"
},
"items" : [
{
"product" : "Product 1",
"description" : "Description Product 1",
"qty" : 2,
"unitprice": 6762
},
{
"product" : "Product 2",
"description" : "Description Product 2",
"qty" : 1,
"unitprice": 222
},
{
"product" : "Product 3",
"description" : "Longer Description Product 3 with more text than product 1 and 2",
"qty" : 6,
"unitprice": 122.88
}
]
}
]
view raw data.json hosted with ❤ by GitHub

It contains the typical elements that should be included on an invoice including invoice meta data, information about the payer, the sold products and payment information. In this sample, the total amount, tax and discount values are calculated using formulas in the template itself.

The following screenshot shows the template. The red annotations show the sub-elements in the JSON data. The blue annotation shows that these cells are calculated based on the data that is merged into the template.

Invoice template

The following animation shows the template and the resulting document after the merge process:

Invoice merging

Test This Sample Template on Your Own

To test this template on your own, follow these easy steps:

  1. Download a trial version of either the Windows Forms, WPF or ASP.NET version.

  2. Start the shipped demo TX Text Control Words from the created start menu entry for TX Text Control.

  3. Download the sample JSON data source from GitHub:

    data.json

  4. Download and unzip the sample template:

    invoice.tx

  5. Load the template into TX Text Control Words.

  6. Select Load JSON File from the Select Data Source drop-down button in the Reporting ribbon tab. Select the downloaded data.json file.

  7. Click Preview from the Finish ribbon group to merge the template.