commit a3928061e2caae9278b06e58245a2135fcafb1d8
Author: lishipeng <1572427111@qq.com>
Date: Fri Mar 3 14:42:03 2023 +0800
first commit
diff --git a/.idea/checkstyle-idea.xml b/.idea/checkstyle-idea.xml
new file mode 100644
index 0000000..c370431
--- /dev/null
+++ b/.idea/checkstyle-idea.xml
@@ -0,0 +1,16 @@
+
+
+
+ 10.5.0
+ JavaOnly
+ true
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..006aace
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
new file mode 100644
index 0000000..e7bedf3
--- /dev/null
+++ b/.idea/copyright/profiles_settings.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..712ab9d
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__commons_codec_commons_codec_1_10.xml b/.idea/libraries/Maven__commons_codec_commons_codec_1_10.xml
new file mode 100644
index 0000000..27424a1
--- /dev/null
+++ b/.idea/libraries/Maven__commons_codec_commons_codec_1_10.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_poi_poi_3_14.xml b/.idea/libraries/Maven__org_apache_poi_poi_3_14.xml
new file mode 100644
index 0000000..4cbf0a1
--- /dev/null
+++ b/.idea/libraries/Maven__org_apache_poi_poi_3_14.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_poi_poi_ooxml_3_13.xml b/.idea/libraries/Maven__org_apache_poi_poi_ooxml_3_13.xml
new file mode 100644
index 0000000..43e4ba9
--- /dev/null
+++ b/.idea/libraries/Maven__org_apache_poi_poi_ooxml_3_13.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_poi_poi_ooxml_schemas_3_13.xml b/.idea/libraries/Maven__org_apache_poi_poi_ooxml_schemas_3_13.xml
new file mode 100644
index 0000000..57bbf23
--- /dev/null
+++ b/.idea/libraries/Maven__org_apache_poi_poi_ooxml_schemas_3_13.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_xmlbeans_xmlbeans_2_6_0.xml b/.idea/libraries/Maven__org_apache_xmlbeans_xmlbeans_2_6_0.xml
new file mode 100644
index 0000000..cb0f76d
--- /dev/null
+++ b/.idea/libraries/Maven__org_apache_xmlbeans_xmlbeans_2_6_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_freemarker_freemarker_2_3_22.xml b/.idea/libraries/Maven__org_freemarker_freemarker_2_3_22.xml
new file mode 100644
index 0000000..d930d57
--- /dev/null
+++ b/.idea/libraries/Maven__org_freemarker_freemarker_2_3_22.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__stax_stax_api_1_0_1.xml b/.idea/libraries/Maven__stax_stax_api_1_0_1.xml
new file mode 100644
index 0000000..0b13335
--- /dev/null
+++ b/.idea/libraries/Maven__stax_stax_api_1_0_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..a194cfe
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,93 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Android
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.8
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..e7f4e6d
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..7c95aa1
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,694 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ DEFINITION_ORDER
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {
+ "keyToString": {
+ "SHARE_PROJECT_CONFIGURATION_FILES": "true",
+ "WebServerToolWindowFactoryState": "false",
+ "last_opened_file_path": "D:/OW/新建文件夹/toWord",
+ "vue.rearran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
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..dd8fdc9
--- /dev/null
+++ b/README.md
@@ -0,0 +1,5 @@
+# toWord
+
+此程序用于从Excel表中读取数据填到word模板中
+
+详见[我的博客](http://www.jianshu.com/p/7dbb7d3e98ee)
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..2c6458f
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,45 @@
+
+
+ 4.0.0
+
+ com.wuchangming.cn
+ toWord
+ 1.0-SNAPSHOT
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 7
+ 7
+
+
+
+
+ jar
+
+ toWord
+ toWord
+
+
+
+ org.freemarker
+ freemarker
+ 2.3.22
+
+
+ org.apache.poi
+ poi
+ 3.14
+
+
+ org.apache.poi
+ poi-ooxml
+ 3.13
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/DocumentHandler.java b/src/main/java/DocumentHandler.java
new file mode 100644
index 0000000..2de847d
--- /dev/null
+++ b/src/main/java/DocumentHandler.java
@@ -0,0 +1,64 @@
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+import freemarker.template.TemplateException;
+
+import java.io.*;
+import java.util.Map;
+
+/**
+ * Created by wuchangming on 17/1/6.
+ */
+public class DocumentHandler {
+
+
+ private Configuration configuration = null;
+
+ public DocumentHandler() {
+ configuration = new Configuration();
+ configuration.setDefaultEncoding("utf-8");
+ }
+
+ public Template getTemplate() throws IOException {
+ configuration.setDirectoryForTemplateLoading(new File("C:\\Users\\Reborn\\Desktop"));
+ Template t = null;
+ try {
+ // data.xml为要装载的模板
+ t = configuration.getTemplate("test.xml");
+ t.setEncoding("utf-8");
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return t;
+ }
+
+ public Writer getWriter(String wordName){
+ String savePath = "C:\\Users\\Reborn\\Desktop\\";
+ File file = new File(savePath+"upload");
+ if(!file.exists()){
+ file.mkdirs();
+ }
+ File outFile = new File(savePath+"upload/"+wordName+".doc");
+ Writer out = null;
+ try {
+ out = new BufferedWriter(new OutputStreamWriter(
+ new FileOutputStream(outFile), "utf-8"));
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+ return out;
+ }
+
+
+ public void createDoc(Template t,Map dataMap,Writer out) {
+ try {
+ t.process(dataMap, out);
+ out.close();
+ } catch (TemplateException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+}
diff --git a/src/main/java/ReadExcelTable.java b/src/main/java/ReadExcelTable.java
new file mode 100644
index 0000000..845c21a
--- /dev/null
+++ b/src/main/java/ReadExcelTable.java
@@ -0,0 +1,118 @@
+/**
+ * Created by wuchangming on 17/1/6.
+ */
+
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 读取上篇中的xls文件的内容,并打印出来
+ *
+ * @author Administrator
+ */
+public class ReadExcelTable {
+
+
+ //通过对单元格遍历的形式来获取信息 ,这里要判断单元格的类型才可以取出值
+ public static List