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>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>com.deepoove</groupId>
<artifactId>poi-tl</artifactId>
<version>1.12.2</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.deepoove</groupId>-->
<!-- <artifactId>poi-tl</artifactId>-->
<!-- <version>1.12.2</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>physical-system-api</artifactId>

View File

@@ -5,19 +5,19 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.deepoove.poi.XWPFTemplate;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.jeecg.common.util.MinioUtil;
import org.jeecg.modules.database.entity.*;
import org.jeecg.modules.database.mapper.ExperimentDocMapper;
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.Value;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.IOException;
import java.io.*;
import java.util.*;
/**
@@ -72,7 +72,10 @@ public class ExperimentDocServiceImpl extends ServiceImpl<ExperimentDocMapper, E
}
log.info("output file path: " + outputFile);
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),
"experiment_doc/" + experimentId + "/" + version + "/" + experiment.getName() + "-" + fileName + ".docx");
return path;