This commit is contained in:
ls
2025-02-08 15:42:32 +08:00
parent 2bdba069f1
commit 969f2adf13
2 changed files with 12 additions and 9 deletions

View File

@@ -23,11 +23,11 @@
<artifactId>poi-ooxml</artifactId> <artifactId>poi-ooxml</artifactId>
<version>4.1.2</version> <version>4.1.2</version>
</dependency> </dependency>
<dependency> <!-- <dependency>-->
<groupId>com.deepoove</groupId> <!-- <groupId>com.deepoove</groupId>-->
<artifactId>poi-tl</artifactId> <!-- <artifactId>poi-tl</artifactId>-->
<version>1.12.2</version> <!-- <version>1.12.2</version>-->
</dependency> <!-- </dependency>-->
<dependency> <dependency>
<groupId>org.jeecgframework.boot</groupId> <groupId>org.jeecgframework.boot</groupId>
<artifactId>physical-system-api</artifactId> <artifactId>physical-system-api</artifactId>

View File

@@ -5,19 +5,19 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.deepoove.poi.XWPFTemplate;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.jeecg.common.util.MinioUtil; import org.jeecg.common.util.MinioUtil;
import org.jeecg.modules.database.entity.*; import org.jeecg.modules.database.entity.*;
import org.jeecg.modules.database.mapper.ExperimentDocMapper; import org.jeecg.modules.database.mapper.ExperimentDocMapper;
import org.jeecg.modules.database.service.*; import org.jeecg.modules.database.service.*;
import org.jeecgframework.poi.word.WordExportUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.File; import java.io.*;
import java.io.IOException;
import java.util.*; import java.util.*;
/** /**
@@ -72,7 +72,10 @@ public class ExperimentDocServiceImpl extends ServiceImpl<ExperimentDocMapper, E
} }
log.info("output file path: " + outputFile); log.info("output file path: " + outputFile);
Map<String, Object> params = assembleParams(experimentId, fileName); Map<String, Object> params = assembleParams(experimentId, fileName);
XWPFTemplate.compile(absolutePath).render(params).writeToFile(outputFile); XWPFDocument doc = WordExportUtil.exportWord07(absolutePath, params);
FileOutputStream fos = new FileOutputStream(outputFile);
doc.write(fos);
fos.close();
String path = MinioUtil.upload(FileUtil.getInputStream(outputFile), String path = MinioUtil.upload(FileUtil.getInputStream(outputFile),
"experiment_doc/" + experimentId + "/" + version + "/" + experiment.getName() + "-" + fileName + ".docx"); "experiment_doc/" + experimentId + "/" + version + "/" + experiment.getName() + "-" + fileName + ".docx");
return path; return path;