SpringBoot+Jxls

1.導入jar包
<!-- https://mvnrepository.com/artifact/org.jxls/jxls -->
<dependency>
<groupId>org.jxls</groupId>
<artifactId>jxls</artifactId>
<version>2.6.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jxls/jxls-poi -->
<dependency>
<groupId>org.jxls</groupId>
<artifactId>jxls-poi</artifactId>
<version>2.6.0-rc1</version>
</dependency>
2.編碼
Context context = new Context();
context.putVar("underwriteExpInfos", underwriteExpInfos);
response.setHeader("content-type", "application/octet-stream");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-Disposition", "attachment;fileName=" + new String(("***.xls").getBytes(),"ISO-8859-1"));
JxlsHelper.getInstance().processTemplate(fis, response.getOutputStream(), context);
3.模板
  第一個單元格添加批註 jx:area(lastCell=」L3」) jxls解析模板面積到3行L列
  第一行數據添加備註 jx:each(items=」underwriteExpInfos」,var=」underwriteExpInfo」,lastCell=」L3」) 行數據解析到3行L列
相關文章
相關標籤/搜索
本站公眾號
   歡迎關注本站公眾號,獲取更多信息