Commit 9bc0af23 authored by linjian's avatar linjian

合同导出修改

parent 3b466121
......@@ -74,6 +74,17 @@
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>fr.opensagres.xdocreport</groupId>
<artifactId>xdocreport</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>ooxml-schemas</artifactId>
<version>1.4</version>
</dependency>
......
......@@ -34,7 +34,7 @@ public class ContractWordServiceldImpl implements ContractWordServiceld {
for(int i = 0; i < request.getData().size(); i++) {
Contract obj = request.getData().get(i);
String fileName = obj.getDESC1()+"-合同会签单.doc";
String fileName = obj.getDESC1()+"-合同会签单.docx";
HashMap<String, Object> map = new HashMap<>();
map.put("DESC1", obj.getDESC1());
map.put("DESC3", obj.getDESC3());
......@@ -46,18 +46,18 @@ public class ContractWordServiceldImpl implements ContractWordServiceld {
map.put("handling_dept", obj.getHandling_dept());
map.put("leader", obj.getLeader());
try {
File catchFile = File.createTempFile(UUID.randomUUID().toString(), ".doc");
File catchFile = File.createTempFile(UUID.randomUUID().toString(), ".docx");
try (
InputStream resource = ContractWordServiceldImpl.class.getClassLoader().getResourceAsStream("word/contract.doc");
InputStream resource = ContractWordServiceldImpl.class.getClassLoader().getResourceAsStream("word/contract.docx");
FileOutputStream fileOutputStream = new FileOutputStream(catchFile);
FileInputStream fileInputStream = new FileInputStream(catchFile);
) {
HWPFDocument word = new HWPFDocument(resource);
Range range = word.getRange();
for (Map.Entry<String, Object> entry : map.entrySet()) {
range.replaceText(entry.getKey(), String.valueOf(entry.getValue()));
}
// WordExportUtil.exportWord07(word, map);
XWPFDocument word = new XWPFDocument(resource);
// Range range = word.getRange();
// for (Map.Entry<String, Object> entry : map.entrySet()) {
// range.replaceText(entry.getKey(), String.valueOf(entry.getValue()));
// }
WordExportUtil.exportWord07(word, map);
word.write(fileOutputStream);
String fileUrl = ossService.uploadOssObject(request.getTenantId(), System.currentTimeMillis() + "/" + fileName, fileInputStream);
fileUrls.add(fileUrl);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment