Browse Source

#施工日志word文档导出

zhongwei
yang_shj 11 months ago
parent
commit
495a8f23d7
  1. 23
      hzims-service/operational/pom.xml
  2. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/ConstructionServiceImpl.java

23
hzims-service/operational/pom.xml

@ -18,6 +18,23 @@
</properties> </properties>
<dependencies> <dependencies>
<!--转pdf-->
<dependency>
<groupId>com.documents4j</groupId>
<artifactId>documents4j-local</artifactId>
<version>${documents4j.version}</version>
</dependency>
<dependency>
<groupId>com.documents4j</groupId>
<artifactId>documents4j-transformer-msoffice-word</artifactId>
<version>${documents4j.version}</version>
</dependency>
<dependency>
<groupId>com.documents4j</groupId>
<artifactId>documents4j-UTIL-ALL</artifactId>
<version>${documents4j.version}</version>
</dependency>
<dependency> <dependency>
<groupId>redis.clients</groupId> <groupId>redis.clients</groupId>
<artifactId>jedis</artifactId> <artifactId>jedis</artifactId>
@ -232,6 +249,12 @@
<artifactId>swagger-bootstrap-ui</artifactId> <artifactId>swagger-bootstrap-ui</artifactId>
<version>${swagger-bootstrap-ui.version}</version> <version>${swagger-bootstrap-ui.version}</version>
</dependency> </dependency>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.xls.free</artifactId>
<version>3.9.1</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/ConstructionServiceImpl.java

@ -88,11 +88,11 @@ public class ConstructionServiceImpl extends BaseServiceImpl<ConstructionMapper,
throw new ServiceException("文件创建失败!"); throw new ServiceException("文件创建失败!");
} }
response.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8");
response.setContentType("application/vnd.ms-excel"); response.setContentType("application/vnd.ms-word");
ServletOutputStream outputStream; ServletOutputStream outputStream;
try { try {
//设置docx格式 //设置docx格式
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName + ".docx", "UTF-8")); response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
//创建一个输出流 //创建一个输出流
outputStream = response.getOutputStream(); outputStream = response.getOutputStream();
//写入数据 //写入数据

Loading…
Cancel
Save