Header widget area left
Header widget area right

Report Builder is a very useful tool for creating bulk reports from a wpDataTable. When multiple files generation logic is chosen, Report Builder creates a separate file for each table row. Just some cases when this is applicable:

  • Welcome letters or routine notifications for clients, employees, partners.
  • Notifications about e.g. exam results for students.
  • Similar commercial offers to a list of clients.

Let’s see an example. This is a dummy database of clients, where each client has an assigned manager, an account number, etc. Try to play around with the table (filter, sort, etc.) and download several versions of bulk report to see how it changes. You can also change the additional notes to see how the field will change in the generated DOCX files.

Clients Database

wdt_IDClientManager NameManager PhoneBusiness TypeAccount Number
1 Xanthus Wong Lisandra Carey (03927) 4533823 Programming 201-466329507-131
2 Ali Gould Damian Martin (032613) 418327 Planning 214-988824748-758
3 Isaac Riley Leilani Sandoval (06266) 4319834 Engineering 201-486183627-601
4 Xenos Burch Rosalyn Vincent (0135) 55876693 Engineering 201-420453148-998
5 Michael Moss Tucker Murray (016) 80222165 Consulting 214-999563484-497
6 Samuel Knox Ingrid Gomez (0591) 41380580 Engineering 214-913702698-420
7 Eaton Christian Nehru Washington (061) 28432972 Planning 214-931646214-625
8 Brittany Woods Graiden Brown (09502) 2056796 Programming 214-938358045-543
9 Alika Savage George Lawrence (0797) 41443062 Insurance 214-919570900-020
10 Alden Stokes Genevieve Mendez (07428) 5716055 Engineering 214-990688506-173
wdt_IDClientManager NameManager PhoneBusiness TypeAccount Number

Let’s see what steps are needed to prepare such a report.

  1. Prepare the source wpDataTable.

Report Builder is an add-on for wpDataTables, so first step is to prepare a wpDataTable with data.

For this example we created a table in table constructor with the following columns: “Client”, “Manager Name”, “Manager Phone”, “Business Type”, “Account Number”.

See how to create tables like this in Table Constructor.

2. Prepare the DOCX template for the report.

Prepare a new DOCX file that would be used as a template for each of generated files. In our case we used in the report:

  • Predefined variables: ${generatorname}, ${today}
  • Additional variables: ${additionalnotes}
  • Cell values from wpDataTable: ${client}, ${businesstype}, ${managername}, ${managerphone}, ${accountnumber}

To download the template we used in this example click here.

See here the full list of rules on creating Report Builder templates.

3. Create a report in WordPress admin page through Report Builder Wizard.

  • Go to WP-admin, open ReportBuilder -> Create a new report
Create New Report in WordPress Report Builder
  • On the first step choose the source wpDataTable:
Bulk DOCX Generator WordPress
  • On the next step provide the report name, choose ‘Multiple file’ generation logic (which means we’ll create a separate file for each row), tick “Follow table filtering”, set the generated filename mask as “${client}-welcome” and define one additional variable – “additionalnotes” with some default value:
Multiple DOCX Generator Settings
    • Then upload the template that you have prepared (click “upload”, drag&drop the file, click “Use template”):
  • On the next step you can download the preview for X first rows of the table:
Download Preview of the DOCX Word File Generated by WordPress Report Builder

If you are satisfied, you can click “Save” to store the result, if something is wrong, you can go back in the wizard and change the settings or upload a different template.

  • Once you click “save”, you will see the shortcodes for this report:
Shortcodes To Download DOCX Generated By WordPress Report Builder

The shortcodes contain buttons for downloading report, saving report to WP Media Library, and for inputs for additional variables.

You can copy these shortcodes directly from this page, but this isn’t necessary as you can always generate these in standard WordPress post/page editor, or in Visual composer.
Once you close the wizard you will be redirected to the Browse page. You can always quickly download the report (for the whole table) from there by clicking the “Download” button, or quickly get the list of available shortcodes.

Browse Reports in WordPress Admin

The last thing to do is to insert the Report controls to the post or page where you need them, so the users would be able to use it.