背景
日常工作中,曾遇到过导出数据为 Word 的需求,这里做个简单总结。
前面分别总结了导出数据为 PDF , Excel 的实现方式,有时候需要在导出文件后进行编辑,那么这时候仅仅导出 PDF 文件是不够的。
下面的实战是基于之前导出数据库表结构为 Word 用到的,后面有 一键导出PostgreSQL数据库表设计为word文档 的实战代码链接。
涉及的技术有: SpringBoot 、 MyBatis 、 lowagie.itext 。
依赖
com.lowagie
itext
2.1.7
com.itextpdf
itext-asian
5.2.0
com.lowagie
itext-rtf
2.1.7
核心导出接口
@Service
public class DataSourceDetailServiceImpl implements DataSourceDetailService {
@Autowired
private DataSourceMapper dataSourceMapper;
@Override
public List
导出效果
Source Code
完整源码见 GitHub :https://github.com/heartsuit/db2word
If you have any questions or any bugs are found, please feel free to contact me.
Your comments and suggestions are welcome!