law-office-system/tcctlo-law-office/src/test/java/com/tcctlo/law/WordTest.java

39 lines
1.4 KiB
Java
Raw Normal View History

2025-02-20 17:25:05 +08:00
package com.tcctlo.law;
import com.deepoove.poi.XWPFTemplate;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import java.io.FileOutputStream;
import java.time.LocalDateTime;
import java.util.HashMap;
@SpringBootTest(classes = LawApplication.class)
public class WordTest {
@Test
void word() throws Exception{
HashMap<String, String> map = new HashMap<>();
map.put("firstParty","甲方名称");
map.put("secondParty","乙方名称");
map.put("solicitor","张三、李四、王五");
map.put("commitment","委托事项委托事项委托事项委托事项");
map.put("signDate", LocalDateTime.now().toString());
map.put("legalRepresentative","法定代表人");
map.put("idNo","620121199708060011");
map.put("creditCode","52031001156477894");
map.put("bankName","中国建设银行");
map.put("accountNum","4561112557894411");
map.put("address","云南省昆明市");
map.put("phone","13359490766");
map.put("facsimile","0931-6554211");
map.put("postcode","730300");
XWPFTemplate template = XWPFTemplate.compile("D:/templeteWord/常年法律顾问合同2023.12版).docx").render(map);
FileOutputStream out = new FileOutputStream("D:/word/常年法律顾问合同.docx");
template.write(out);
out.flush();
out.close();
template.close();
}
}