先看效果图
需要pom导入jar包
<!-- excel文档操作 -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
</dependency>
先写一个工具类 ExcelUtil
然后在Controller里使用
可以合并表格
结果类似下图
字体大小或者背景色之类的设置可以自行百度或者看HSSFCellStyle类属性和方法;
后续会再封装一个稍微复杂一些的方法
代码已上传Git https://gitee.com/lafar/export_excel