Commit a19cf9d9 by yuwei

2.0.0项目初始化

parent ce3bd70b
...@@ -127,14 +127,9 @@ public class WordUtil { ...@@ -127,14 +127,9 @@ public class WordUtil {
* @param destPath 文件路径 F:\\test\\审批流提交.docx * @param destPath 文件路径 F:\\test\\审批流提交.docx
* @return * @return
*/ */
public boolean newWord(String destPath) { public void createWord(String destPath) throws Exception {
try {
Document doc = new Document(); Document doc = new Document();
doc.save(destPath, SaveOptions.createSaveOptions(SaveFormat.DOCX)); doc.save(destPath, SaveOptions.createSaveOptions(SaveFormat.DOCX));
return true;
} catch (Exception e) {
return false;
}
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
...@@ -154,7 +149,13 @@ public class WordUtil { ...@@ -154,7 +149,13 @@ public class WordUtil {
map2.put("sex", "女"); map2.put("sex", "女");
map2.put("salary", new BigDecimal("7.34")); map2.put("salary", new BigDecimal("7.34"));
list.add(map2); list.add(map2);
WordUtil.getInstance().fillWordListData(new String[]{"companyName", "totalSalary"}, new Object[]{"测试", new BigDecimal("12.34")}, "F:\\test\\模板.docx", "F:\\test\\123.docx", list, "workerList"); List<String> objects1 = new ArrayList<>();
List<Object> objects2 = new ArrayList<>();
for(Map.Entry<String, Object> entry : map.entrySet()){
objects1.add(entry.getKey());
objects2.add(entry.getValue());
}
WordUtil.getInstance().fillWordListData(objects1.toArray(new String[objects1.size()]), objects2.toArray(new Object[objects2.size()]), "F:\\test\\模板.docx", "F:\\test\\123.docx", list, "workerList");
// WordUtil.getInstance().word2pdf("F:\\test\\审批流提交.docx", "F:\\test\\20200420.pdf"); // WordUtil.getInstance().word2pdf("F:\\test\\审批流提交.docx", "F:\\test\\20200420.pdf");
} }
} }
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