Wordgo: How to generate word in java

When it comes to Java generating word, the first reaction may be POI, but today I recommend a super easy-to-use "wheel" wordGo

Its CSS-like writing method allows you to get started quickly, and it does not require templates and does not rely on any third-party office components.

Traditional Java generation of word usually requires manually creating a template file and then importing it. If you don’t want to create templates and want to use less code, it’s a good idea to choose Word GO~~

Install

Manually import jar packages

  • IDEA import: Click File-Project Structure; then find Modules on the left and click on it; finally click on the green + sign on the right, select JARs or directories and select the jar package to be imported.
  • Eclipse import: right-click "Project" → select Properties, select Java Build Path in the list on the left side of the pop-up dialog box

maven central warehouse import

<dependency>
 <groupId>com.github.qrpcode</groupId>
 <artifactId>wordgo</artifactId>
 <version>1.0-SNAPSHOT</version>
</dependency>

It is perfectly compatible with domestic desktop programs and comes with a large number of styles, such as tables, and comes with 105 templates just like Microsoft Office!

æçå¼å®¹æ§

use

Come on, after importing the jar package, let’s first create a “Hello World”

WordGo wordGo = new WordGo();
//新建一个word
wordGo.add("Hello World", "font-size: 15; color: #FF0000");
//填充数据可以查看对应功能说明
wordGo.create("C:\\demo.docx");
//最后生成即可,参数是生成目录,必须带文件名且以.docx结尾

Yes, it is very similar to CSS writing method and is easy to get started~~

For more detailed writing methods, you can view the official documentation: https://github.com/qrpcode/wordgo

Guess you like

Origin blog.csdn.net/qq_20051535/article/details/107820944