认证-上报库-自定义导出word修改

This commit is contained in:
liyawei
2022-07-08 18:39:56 +08:00
parent 6fe37e6b50
commit 2174761154
@@ -695,6 +695,7 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
downLoadFileList(allRelevFileList,fileNowPath + File.separator + "导出文件");
}
// 拿取模板
String repFileName = fileName.replaceAll("/","_");
wordOS = new FileOutputStream(fileNowPath + File.separator + repFileName);
if (CosBootUtil.doesObjectExist(templateUrl)) {
@@ -702,24 +703,32 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
com.qcloud.cos.utils.IOUtils.copy(wordTemplate, wordOS);
}
byte[] wordContent = Docx4jUtil.of(fileNowPath + File.separator + repFileName).addParam("title", "测试文档标题")
// 替换占位符内容
byte[] wordContent = Docx4jUtil.of(fileNowPath + File.separator + repFileName)
.addParams(params)
.get();
ByteArrayInputStream wordis = new ByteArrayInputStream(wordContent);
OutputStream wordFileOS = new FileOutputStream(fileNowPath + File.separator + repFileName);
int len1 = 0;
while ((len1 = wordis.read()) != -1) {
wordFileOS.write(len1);
}
wordOS.flush();
wordOS.close();
wordFileOS.flush();
wordFileOS.close();
// 打包导出压缩包
response.setHeader("Content-Disposition",
"attachment; filename=\""+ ReadExcel.encodeFileName(fileOriName+".zip", request) +"\"");
response.setContentType("application/force-download");
response.flushBuffer();
os = response.getOutputStream();
wordOS.flush();
wordOS.close();
ZipUtil.zip(fileNowPath,fileNowPath+".zip");
// FileInputStream fis = new FileInputStream(fileNowPath+".zip");
ByteArrayInputStream fis = new ByteArrayInputStream(wordContent);
int len = 0;
while ((len = fis.read()) != -1) {
os.write(len);
FileInputStream fis = new FileInputStream(fileNowPath+".zip");
int len2 = 0;
while ((len2 = fis.read()) != -1) {
os.write(len2);
}
// 添加导出历史