A practical example of exporting word with freemaker in Java
•
Java
In a recent project, I had to export word documents for a long time. I found that it was more convenient and easy to use freemaker's template. Now I summarize the key steps for your reference. Here is a simple example of test paper generation.
1. Template making
First make a template with word, as shown in the following figure:
2、 Programming implementation
Freemaker-2.3 is used here 13. Jar package, the code is as follows:
Then prepare the data call. The code is as follows:
Note that the keys in the above map must correspond to those in the template, otherwise an error will be reported. The effects are as follows:
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码