Get Started Generating Word/PDF Reports Quickly With Templates
Word is a powerful and versatile word processing software that can help you create various types of professional documents for your business. Here are some reasons why Word is important in the business field nowadays:
- Word allows you to create letters, mailings, forms, reports, proposals, and other documents with ease and efficiency. You can use templates, styles, themes, and data visualization tools to make your documents look consistent and appealing.
- Word enables you to collaborate with your colleagues and clients online. You can share, edit, and comment on documents in real time using Office 365 and OneDrive. You can also use Word’s integration with other Microsoft apps, such as Outlook, Excel, and PowerPoint, to enhance your productivity and communication.
- Word helps you produce promotional and marketing materials for your business. You can design and print your own brochures, flyers, newsletters, letterheads, and business cards using Word’s features and tools. You can also use Word to create online content, such as blogs, web pages, and ebooks.
- Word supports your brand building and identity. You can customize your documents with your logo, colors, fonts, and images to reflect your business’s values and vision. You can also use Word to create certificates and awards for your employees and customers
How to generate a custom Word document using data from database/JSON?
Benefits
Generating a custom Word document from a database or JSON file with a Word template has several benefits, such as:
- It saves you time and effort by automating the document creation process. You don’t have to manually enter the data or format the document. You can use a predefined template that suits your needs and populate it with the data from your source.
- It ensures consistency and accuracy of your documents. You can avoid errors and typos by using the data from your source, which is more reliable and up-to-date than manual input. You can also maintain a uniform style and layout for your documents by using the same template.
- It allows you to customize and personalize your documents. You can use various features and tools in Word to modify your template and add dynamic elements, such as images, charts, tables, and conditional statements. You can also use different languages and formats for your data, such as JSON, XML, CSV, etc.
- It enables you to share and distribute your documents easily. You can export your documents to various formats, such as PDF, HTML, or TXT, and send them to your recipients via email, cloud, or web.
Install Rapid Reporting Tools
- Click Download Rapid Reporting Tools , save it in any folder you want.
- Unzip the rapid-report.zip file, extract all files in to a folder.
- Go to the extracted folder. There is a file named rapid-report.exe in it.
- Double-click the rapid-report.exe file, follow the wizard to install it in the default folder.
- If it is the first time you install this software, several folders for storing configuration files will be created when you start the installed executable.
Start Rapid Reporting Tools
Start Rapid Report by clicking Rapid Report menu from the start menu, and then you will see the application looks like this:
Now, please click Play button to start the server. You may see this dialog and please click Allow.
Login Rapid Report Web UI
The Rapid Report provides a web-based GUI interface for users to configure the server, run the reports etc.
Open your browser and point it to this link:
http://localhost:8007/#/
You will see the login form. Please fill in username and password, and Login. If you don’t know username and password, please click Forget password link, and a guide appear.
The initial username is admin, and corresponding password is admin also, please change the initial password as soon as possible
Create Your First Report
Click Report List menu on the left-hand side of web console, and go to report list page. It is the first time you login, so no report listed in it. Let’s create the first one.
Click New button and fill in template name description.
The template name (also report name) is very critical, it works like file name and is referred frequently. So, its name should be unique.
Please name it sample-template now, because other documents/sample project refer this report also.
Click Next.
And upload template page comes up. As a beginner, you don’t have your customized template, so, please select the sample-template.docx file, and upload it.
Check out sample template sample-template.docx
After installing Rapid Report Server (hereinafter call the software), please go to the installation path (i.e. C:\Program Files (x86)\Rapid Report), you will see the examples folder in the root folder of installation path. Go to examples folder, and see the sample-template.docx file. We offer this template to help you learn how to build you own report and template.
It is recommended that you open the template file with Word, and check it out. It looks like this:
Click Next.
Now, you need to set some parameter names. Please choose option or fill in name as below.
Click Next
Click Done
Go back to Report Templates list page, a report is listed in it.
** RUN THE FIRST REPORT.
Click Mock Run menu, then click Mock Run via JSON.
You will see the page like this. You can change the JSON parameter value if you want.
The data in JSON format:
{
"total" : "v_total",
"table1" : [ {
"price" : "v_price",
"name" : "v_name",
"id" : "v_id"
}, {
"price" : "v_price",
"name" : "v_name",
"id" : "v_id"
}, {
"price" : "v_price",
"name" : "v_name",
"id" : "v_id"
} ],
"chart1" : {
"series" : [ {
"serieData" : [ 6, 1, 2 ],
"serieLabel" : "series 1"
}, {
"serieData" : [ 5, 3, 1 ],
"serieLabel" : "series 2"
}, {
"serieData" : [ 7, 6, 8 ],
"serieLabel" : "series 3"
} ],
"categories" : [ "Category 1", "Category 2", "Category 3" ],
"title" : "Sample Chart"
},
"name" : "v_name",
"image1" : "https://www.lv2000.com/",
"list" : [ "v_list_1", "v_list_2", "v_list_3" ]
}
Click Submit
Wait for 1 second, you will see a Download link.
Download the output, and open, the Word file looks like:
As you can see, the {{name}} string was replaced with v_name, and the image was replaced with a QR code image.
Compare the output with the template
RUN THE REPORT WITH CUSTOMIZED PARAMETERS.
You can pass parameter via JSON string, but it is a bit complex. Now you can try the “Mock Run via Form” feature. The form looks like:
RUN THE REPORT VIA YOUR PROGRAM.
In general, it is not convenient to run report manually, you may want your program/application to call report server to generate report output as you want.
The software offers API to fulfill this requirement. And we also offer sample code for you. The source code below is for Java programmer. If you have any questions or special needs, please contact the vendor.
public static void main(String[] args) throws Exception {
HashMap dataMap=new HashMap();
ArrayList<Map<String, String>> tableData=new ArrayList<>();
{
Map<String, String> map = new HashMap<>();
map.put("name", "Name 1");
map.put("id", "1");
map.put("price", "1.00");
tableData.add(map);
}
{
Map<String, String> map = new HashMap<>();
map.put("name", "Name 2");
map.put("id", "2");
map.put("price", "2.00");
tableData.add(map);
}
Map<String, Object> chart=new HashMap<>();
chart.put("title", "Sample Title");
ArrayList<String> categories=new ArrayList<>();
ArrayList<Map> series = new ArrayList<>();
for(int i=0;i<3;i++){
Map<String, Object> map = new HashMap<>();
map.put("serieLabel", "Series "+(i+1));
map.put("serieData", new ArrayList());
series.add( map);
}
for(int i=0;i<3;i++) {
categories.add("Category "+(i+1));
for(Map map :series) {
((ArrayList)map.get("serieData")).add((int)(Math.random()*10));
}
}
chart.put("categories", categories);
chart.put("series", series);
dataMap.put("name", "John");
dataMap.put("total", "3.00");
dataMap.put("image1", "https://www.lv2000.com");
dataMap.put("list", Arrays.asList("description 1", "description 2", "description 3"));
dataMap.put("table1", tableData);
dataMap.put("chart1", chart);
String callerId="39cc2f16befb4fb7b6060b6f97ce6edf"; //To be changed
//To be changed
String privateKey= "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqpmS0a8vs6mJ4p6eAU88Iy4Mm5Ltf6t9NgR+ahUV2woPnTd2ips9/DNREL+z3GtEG6bbypGFVislFvhSFgicFA1NUxvo3tsQzLHvbJVZuTzZXRuXNtC+C8jzVJqOVygiLTEm3YoM51mYg3R1KBJ4d0vWtkiGdgB9kqIHS5b3RCZ2XSy6R2aE2ysZpFHF459wgKdUMO2TvRQb6QYAYYG6DrFS5xaVFGqgRRaR825nukiR6NupJm4CDd1Ec+hOvF4ohbaSKUCajIq/gT7YQAkn9OH7ckUZ04ivAaTLX6lVPpDPCAlNmEr/TE2qvcCuoCA4ZUAPCUQX04BCjCkAizB1cQIDAQAB";
String templateName = "sample-template"; //"template name here";
final String serverLocation="http://10.211.55.6:8007";//To be changed
String mailTo = null;
String mailTemplateId = null;
CallRapidReportServerUtil.callRapidRepAPI(
serverLocation,
dataMap,
callerId,
privateKey,
templateName,
mailTo,
mailTemplateId);
}
TRY REPORT WITH LOOP LOGIC.
Please try sample-template2.docx template in the installation path. The sample client code is listed in Test2.java.