java连接数据库利用freemark导出word

这个星期做数据字典功能,有一项任务就是将数据库中的每个表的字段导出,生成word文档,在综合比较网上各种技术之后,参照csdn上骆豪的博客完成了任务。

骆昊的链接:http://blog.csdn.net/jackfrued/article/details/39449021

首先打开word文档,建立自己所需要的模板,然后将word保存为XML的格式,这里可能出现的一个问题就是需要填入的内容放上${}占位符的时候可能会出现字符分离的情况,所以建议先将需要用${}占位符的地方用中文写在word里然后保存为XML的格式,再打开XML对需要用${}占位符的地方进行替换,这样就避免了字符分离的情况。推荐使用一个软件,foxe,这个软件编辑XML很方便,如下图所示,按F8可以对XML进行格式化,然后再对XML进行编辑。


将需要用${}占位符输出的字段替换好之后,将文件另存为ftl格式即可。

将freemarker的jar包导入lib之后,开始编写代码。

因为项目需要,我是需要将数据库中的表的和表的字段都读取出来,所以可以使用两层list进行封装。

首先,使用一个Java bean封装,代码如图所示


 
 
  1. import java.util.List;
  2. public class allTables {
  3. String title;
  4. String commont;
  5. int count;
  6. List<CommonDictionary> commonDictionaries;
  7. public String getCommont() {
  8. return commont;
  9. }
  10. public void setCommont(String commont) {
  11. this.commont = commont;
  12. }
  13. public int getCount() {
  14. return count;
  15. }
  16. public void setCount(int count) {
  17. this.count = count;
  18. }
  19. public String getTitle() {
  20. return title;
  21. }
  22. public void setTitle(String title) {
  23. this.title = title;
  24. }
  25. public List<CommonDictionary> getCommonDictionaries() {
  26. return commonDictionaries;
  27. }
  28. public void setCommonDictionaries(List<CommonDictionary> commonDictionaries) {
  29. this.commonDictionaries = commonDictionaries;
  30. }
  31. }

这个Javabean是对表进行进行封装,然后再使用一个Javabean对表的属性进行封装,如图所示:


 
 
  1. package cn.changhong.dictionary.domain;
  2. import java.util.Date;
  3. public class CommonDictionary {
  4. String cId;
  5. String cName;
  6. String cCommont;
  7. String cDataType;
  8. String primaryKey;
  9. String createUser;
  10. Date createTime;
  11. String updateUser;
  12. Date updateTime;
  13. String cLength;
  14. int num;
  15. String isNull;
  16. public String getIsNull() {
  17. return isNull;
  18. }
  19. public void setIsNull(String isNull) {
  20. this.isNull = isNull;
  21. }
  22. public int getNum() {
  23. return num;
  24. }
  25. public void setNum(int num) {
  26. this.num = num;
  27. }
  28. public Date getCreateTime() {
  29. return createTime;
  30. }
  31. public void setCreateTime(Date createTime) {
  32. this.createTime = createTime;
  33. }
  34. public Date getUpdateTime() {
  35. return updateTime;
  36. }
  37. public void setUpdateTime(Date updateTime) {
  38. this.updateTime = updateTime;
  39. }
  40. public String getcId() {
  41. return cId;
  42. }
  43. public void setcId(String cId) {
  44. this.cId = cId;
  45. }
  46. public String getcName() {
  47. return cName;
  48. }
  49. public void setcName(String cName) {
  50. this.cName = cName;
  51. }
  52. public String getcCommont() {
  53. return cCommont;
  54. }
  55. public void setcCommont(String cCommont) {
  56. this.cCommont = cCommont;
  57. }
  58. public String getcDataType() {
  59. return cDataType;
  60. }
  61. public void setcDataType(String cDataType) {
  62. this.cDataType = cDataType;
  63. }
  64. public String getPrimaryKey() {
  65. return primaryKey;
  66. }
  67. public void setPrimaryKey(String primaryKey) {
  68. this.primaryKey = primaryKey;
  69. }
  70. public String getCreateUser() {
  71. return createUser;
  72. }
  73. public void setCreateUser(String createUser) {
  74. this.createUser = createUser;
  75. }
  76. public String getUpdateUser() {
  77. return updateUser;
  78. }
  79. public void setUpdateUser(String updateUser) {
  80. this.updateUser = updateUser;
  81. }
  82. public String getcLength() {
  83. return cLength;
  84. }
  85. public void setcLength(String cLength) {
  86. this.cLength = cLength;
  87. }
  88. }

项目的结构如下图:


在WordDownController层将数据封装好。

代码如下:


 
 
  1. package cn.changhong.dictionary.controller;
  2. import java.io.File;
  3. import java.io.FileInputStream;
  4. import java.io.IOException;
  5. import java.io.InputStream;
  6. import java.util.ArrayList;
  7. import java.util.HashMap;
  8. import java.util.List;
  9. import java.util.Map;
  10. import javax.servlet.ServletOutputStream;
  11. import javax.servlet.http.HttpServletRequest;
  12. import javax.servlet.http.HttpServletResponse;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.stereotype.Controller;
  15. import org.springframework.web.bind.annotation.RequestMapping;
  16. import cn.changhong.dictionary.domain.CommonDictionary;
  17. import cn.changhong.dictionary.domain.DcTable;
  18. import cn.changhong.dictionary.domain.allTables;
  19. import cn.changhong.dictionary.service.CommonDictionaryService;
  20. import cn.changhong.dictionary.util.WordGenerator;
  21. import cn.changhong.system.util.BaseDaoSupport;
  22. @Controller
  23. @RequestMapping( "/word")
  24. public class WordDownController extends BaseDaoSupport {
  25. @Autowired
  26. CommonDictionaryService cs;
  27. @RequestMapping( "/down")
  28. public void download(HttpServletRequest req, HttpServletResponse resp) throws IOException {
  29. req.setCharacterEncoding( "utf-8");
  30. Map<String, Object> map = new HashMap<String, Object>();
  31. /*
  32. * map.put("title","哈哈"); map.put("num", 1); map.put("cName",2);
  33. * map.put("cCommont", 3); map.put("cDataType",4); map.put("cLength",
  34. * 5); map.put("primaryKey", 6);
  35. */
  36. try {
  37. List<allTables> aTables = new ArrayList<allTables>();
  38. List<DcTable> tables = cs.qureyalltables(); //选出所有的表名
  39. int j= 1;
  40. for (DcTable table : tables) {
  41. int i = 1;
  42. List<CommonDictionary> colums = cs.querycolumnbytable(table.gettName()); //选出每个表的属性
  43. for (CommonDictionary column : colums) { //增加序号
  44. column.setNum(i);
  45. if(column.getPrimaryKey().equals( "0")){
  46. column.setPrimaryKey( "✘");
  47. } else if(column.getPrimaryKey().equals( "1")){
  48. column.setPrimaryKey( "✔");
  49. }
  50. if(column.getIsNull().equals( "0")){
  51. column.setIsNull( "✔");
  52. } else if(column.getIsNull().equals( "1")){
  53. column.setIsNull( "✘");
  54. }
  55. i++;
  56. }
  57. allTables allTables = new allTables();
  58. allTables.setTitle(table.gettName());
  59. allTables.setCount(j);
  60. allTables.setCommont(table.gettCommont());
  61. allTables.setCommonDictionaries(colums);
  62. aTables.add(allTables); //放入list里面
  63. j++;
  64. }
  65. map.put( "listmap", aTables); //放入map里面
  66. } catch (Exception e) {
  67. // TODO: handle exception
  68. }
  69. /*
  70. * Enumeration<String> paramNames = req.getParameterNames(); //
  71. * 通过循环将表单参数放入键值对映射中 while(paramNames.hasMoreElements()) { String key =
  72. * paramNames.nextElement(); String value = req.getParameter(key);
  73. * map.put(key, value); }
  74. */
  75. // 提示:在调用工具类生成Word文档之前应当检查所有字段是否完整
  76. // 否则Freemarker的模板殷勤在处理时可能会因为找不到值而报错 这里暂时忽略这个步骤了
  77. File file = null;
  78. InputStream fin = null;
  79. ServletOutputStream out = null;
  80. try {
  81. // 调用工具类WordGenerator的createDoc方法生成Word文档
  82. file = WordGenerator.createDoc(map, "resume");
  83. fin = new FileInputStream(file);
  84. resp.setCharacterEncoding( "utf-8");
  85. resp.setContentType( "application/msword");
  86. // 设置浏览器以下载的方式处理该文件默认名为resume.doc
  87. resp.addHeader( "Content-Disposition", "attachment;filename=resume.doc");
  88. out = resp.getOutputStream();
  89. byte[] buffer = new byte[ 512]; // 缓冲区
  90. int bytesToRead = - 1;
  91. // 通过循环将读入的Word文件的内容输出到浏览器中
  92. while ((bytesToRead = fin.read(buffer)) != - 1) {
  93. out.write(buffer, 0, bytesToRead);
  94. }
  95. } finally {
  96. if (fin != null)
  97. fin.close();
  98. if (out != null)
  99. out.close();
  100. if (file != null)
  101. file.delete(); // 删除临时文件
  102. }
  103. }
  104. }

将数据封装放到list里面,然后放入map.

在ftl 利用<#list>标签进行两次循环即可取出数据。

ftl的代码片段如下:


 
 
  1. <w:body>
  2. <#list listmap as maps>
  3. <w:p>
  4. <w:pPr>
  5. <w:rPr>
  6. <w:rFonts w:hint="eastAsia"/>
  7. <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
  8. </w:rPr>
  9. </w:pPr>
  10. <w:bookmarkStart w:id="0" w:name="_GoBack"/>
  11. <w:bookmarkEnd w:id="0"/>
  12. <w:r>
  13. <w:rPr>
  14. <w:rFonts w:hint="eastAsia"/>
  15. <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
  16. </w:rPr>
  17. <w:t>表名:${maps.title} </w:t>
  18. </w:r>
  19. </w:p>
  20. <w:tbl>
  21. <w:tblPr>
  22. <w:tblStyle w:val="4"/>
  23. <w:tblW w:w="7304" w:type="dxa"/>
  24. <w:tblInd w:w="0" w:type="dxa"/>
  25. <w:tblBorders>
  26. <w:top w:val="single" w:color="auto" w:sz="4" w:space="0"/>
  27. <w:left w:val="single" w:color="auto" w:sz="4" w:space="0"/>
  28. <w:bottom w:val="single" w:color="auto" w:sz="4" w:space="0"/>
  29. <w:right w:val="single" w:color="auto" w:sz="4" w:space="0"/>
  30. <w:insideH w:val="single" w:color="auto" w:sz="4" w:space="0"/>
  31. <w:insideV w:val="single" w:color="auto" w:sz="4" w:space="0"/>
  32. </w:tblBorders>
  33. <w:tblLayout w:type="fixed"/>
  34. <w:tblCellMar>
  35. <w:top w:w="0" w:type="dxa"/>
  36. <w:left w:w="108" w:type="dxa"/>
  37. <w:bottom w:w="0" w:type="dxa"/>
  38. <w:right w:w="108" w:type="dxa"/>
  39. </w:tblCellMar>
  40. </w:tblPr>
  41. <w:tblGrid>
  42. <w:gridCol w:w="1217"/>
  43. <w:gridCol w:w="1217"/>
  44. <w:gridCol w:w="1217"/>
  45. <w:gridCol w:w="1217"/>
  46. <w:gridCol w:w="1218"/>
  47. <w:gridCol w:w="1218"/>
  48. </w:tblGrid>
  49. <w:tr>
  50. <w:tblPrEx>
  51. <w:tblBorders>
  52. <w:top w:val="single" w:color="auto" w:sz="4" w:space="0"/>
  53. <w:left w:val="single" w:color="auto" w:sz="4" w:space="0"/>
  54. <w:bottom w:val="single" w:color="auto" w:sz="4" w:space="0"/>
  55. <w:right w:val="single" w:color="auto" w:sz="4" w:space="0"/>
  56. <w:insideH w:val="single" w:color="auto" w:sz="4" w:space="0"/>
  57. <w:insideV w:val="single" w:color="auto" w:sz="4" w:space="0"/>
  58. </w:tblBorders>
  59. <w:tblLayout w:type="fixed"/>
  60. <w:tblCellMar>
  61. <w:top w:w="0" w:type="dxa"/>
  62. <w:left w:w="108" w:type="dxa"/>
  63. <w:bottom w:w="0" w:type="dxa"/>
  64. <w:right w:w="108" w:type="dxa"/>
  65. </w:tblCellMar>
  66. </w:tblPrEx>
  67. <w:tc>
  68. <w:tcPr>
  69. <w:tcW w:w="1217" w:type="dxa"/>
  70. </w:tcPr>
  71. <w:p>
  72. <w:pPr>
  73. <w:rPr>
  74. <w:rFonts w:hint="eastAsia"/>
  75. <w:vertAlign w:val="baseline"/>
  76. <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
  77. </w:rPr>
  78. </w:pPr>
  79. <w:r>
  80. <w:rPr>
  81. <w:rFonts w:hint="eastAsia"/>
  82. <w:vertAlign w:val="baseline"/>
  83. <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
  84. </w:rPr>
  85. <w:t>序号 </w:t>
  86. </w:r>
  87. </w:p>
  88. </w:tc>
  89. <w:tc>
  90. <w:tcPr>
  91. <w:tcW w:w="1217" w:type="dxa"/>
  92. </w:tcPr>
  93. <w:p>
  94. <w:pPr>
  95. <w:rPr>
  96. <w:rFonts w:hint="eastAsia"/>
  97. <w:vertAlign w:val="baseline"/>
  98. <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
  99. </w:rPr>
  100. </w:pPr>
  101. <w:r>
  102. <w:rPr>
  103. <w:rFonts w:hint="eastAsia"/>
  104. <w:vertAlign w:val="baseline"/>
  105. <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
  106. </w:rPr>
  107. <w:t>字段 </w:t>
  108. </w:r>
  109. </w:p>
  110. </w:tc>
  111. <w:tc>
  112. <w:tcPr>
  113. <w:tcW w:w="1217" w:type="dxa"/>
  114. </w:tcPr>
  115. <w:p>
  116. <w:pPr>
  117. <w:rPr>
  118. <w:rFonts w:hint="eastAsia"/>
  119. <w:vertAlign w:val="baseline"/>
  120. <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
  121. </w:rPr>
  122. </w:pPr>
  123. <w:r>
  124. <w:rPr>
  125. <w:rFonts w:hint="eastAsia"/>
  126. <w:vertAlign w:val="baseline"/>
  127. <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
  128. </w:rPr>
  129. <w:t>备注 </w:t>
  130. </w:r>
  131. </w:p>
  132. </w:tc>
  133. <w:tc>
  134. <w:tcPr>
  135. <w:tcW w:w="1217" w:type="dxa"/>
  136. </w:tcPr>
  137. <w:p>
  138. <w:pPr>
  139. <w:rPr>
  140. <w:rFonts w:hint="eastAsia"/>
  141. <w:vertAlign w:val="baseline"/>
  142. <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
  143. </w:rPr>
  144. </w:pPr>
  145. <w:r>
  146. <w:rPr>
  147. <w:rFonts w:hint="eastAsia"/>
  148. <w:vertAlign w:val="baseline"/>
  149. <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
  150. </w:rPr>
  151. <w:t>数据类型 </w:t>
  152. </w:r>
  153. </w:p>
  154. </w:tc>
  155. <w:tc>
  156. <w:tcPr>
  157. <w:tcW w:w="1218" w:type="dxa"/>
  158. </w:tcPr>
  159. <w:p>
  160. <w:pPr>
  161. <w:rPr>
  162. <w:rFonts w:hint="eastAsia"/>
  163. <w:vertAlign w:val="baseline"/>
  164. <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
  165. </w:rPr>
  166. </w:pPr>
  167. <w:r>
  168. <w:rPr>
  169. <w:rFonts w:hint="eastAsia"/>
  170. <w:vertAlign w:val="baseline"/>
  171. <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
  172. </w:rPr>
  173. <w:t>长度 </w:t>
  174. </w:r>
  175. </w:p>
  176. </w:tc>
  177. <w:tc>
  178. <w:tcPr>
  179. <w:tcW w:w="1218" w:type="dxa"/>
  180. </w:tcPr>
  181. <w:p>
  182. <w:pPr>
  183. <w:rPr>
  184. <w:rFonts w:hint="eastAsia"/>
  185. <w:vertAlign w:val="baseline"/>
  186. <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
  187. </w:rPr>
  188. </w:pPr>
  189. <w:r>
  190. <w:rPr>
  191. <w:rFonts w:hint="eastAsia"/>
  192. <w:vertAlign w:val="baseline"/>
  193. <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
  194. </w:rPr>
  195. <w:t>是否主键 </w:t>
  196. </w:r>
  197. </w:p>
  198. </w:tc>
  199. </w:tr>
  200. <#list maps.commonDictionaries as commonDictionary>
  201. <w:tr>
  202. <w:tblPrEx>
  203. <w:tblBorders>
  204. <w:top w:val="single" w:color="auto" w:sz="4" w:space="0"/>
  205. <w:left w:val="single" w:color="auto" w:sz="4" w:space="0"/>
  206. <w:bottom w:val="single" w:color="auto" w:sz="4" w:space="0"/>
  207. <w:right w:val="single" w:color="auto" w:sz="4" w:space="0"/>
  208. <w:insideH w:val="single" w:color="auto" w:sz="4" w:space="0"/>
  209. <w:insideV w:val="single" w:color="auto" w:sz="4" w:space="0"/>
  210. </w:tblBorders>
  211. <w:tblLayout w:type="fixed"/>
  212. <w:tblCellMar>
  213. <w:top w:w="0" w:type="dxa"/>
  214. <w:left w:w="108" w:type="dxa"/>
  215. <w:bottom w:w="0" w:type="dxa"/>
  216. <w:right w:w="108" w:type="dxa"/>
  217. </w:tblCellMar>
  218. </w:tblPrEx>
  219. <w:tc>
  220. <w:tcPr>
  221. <w:tcW w:w="1217" w:type="dxa"/>
  222. <w:textDirection w:val="lrTb"/>
  223. <w:vAlign w:val="top"/>
  224. </w:tcPr>
  225. <w:p>
  226. <w:pPr>
  227. <w:rPr>
  228. <w:rFonts w:hint="eastAsia"/>
  229. <w:vertAlign w:val="baseline"/>
  230. <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
  231. </w:rPr>
  232. </w:pPr>
  233. <w:r>
  234. <w:rPr>
  235. <w:rFonts w:hint="eastAsia"/>
  236. <w:vertAlign w:val="baseline"/>
  237. <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
  238. </w:rPr>
  239. <w:t>${commonDictionary.num} </w:t>
  240. </w:r>
  241. </w:p>
  242. </w:tc>
  243. <w:tc>
  244. <w:tcPr>
  245. <w:tcW w:w="1217" w:type="dxa"/>
  246. <w:textDirection w:val="lrTb"/>
  247. <w:vAlign w:val="top"/>
  248. </w:tcPr>
  249. <w:p>
  250. <w:pPr>
  251. <w:rPr>
  252. <w:rFonts w:hint="eastAsia"/>
  253. <w:vertAlign w:val="baseline"/>
  254. <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
  255. </w:rPr>
  256. </w:pPr>
  257. <w:r>
  258. <w:rPr>
  259. <w:rFonts w:hint="eastAsia"/>
  260. <w:vertAlign w:val="baseline"/>
  261. <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
  262. </w:rPr>
  263. <w:t>${commonDictionary.cName} </w:t>
  264. </w:r>
  265. </w:p>
  266. </w:tc>
  267. <w:tc>
  268. <w:tcPr>
  269. <w:tcW w:w="1217" w:type="dxa"/>
  270. <w:textDirection w:val="lrTb"/>
  271. <w:vAlign w:val="top"/>
  272. </w:tcPr>
  273. <w:p>
  274. <w:pPr>
  275. <w:rPr>
  276. <w:rFonts w:hint="eastAsia"/>
  277. <w:vertAlign w:val="baseline"/>
  278. <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
  279. </w:rPr>
  280. </w:pPr>
  281. <w:r>
  282. <w:rPr>
  283. <w:rFonts w:hint="eastAsia"/>
  284. <w:vertAlign w:val="baseline"/>
  285. <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
  286. </w:rPr>
  287. <w:t>${commonDictionary.cCommont} </w:t>
  288. </w:r>
  289. </w:p>
  290. </w:tc>
  291. <w:tc>
  292. <w:tcPr>
  293. <w:tcW w:w="1217" w:type="dxa"/>
  294. <w:textDirection w:val="lrTb"/>
  295. <w:vAlign w:val="top"/>
  296. </w:tcPr>
  297. <w:p>
  298. <w:pPr>
  299. <w:rPr>
  300. <w:rFonts w:hint="eastAsia"/>
  301. <w:vertAlign w:val="baseline"/>
  302. <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
  303. </w:rPr>
  304. </w:pPr>
  305. <w:r>
  306. <w:rPr>
  307. <w:rFonts w:hint="eastAsia"/>
  308. <w:vertAlign w:val="baseline"/>
  309. <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
  310. </w:rPr>
  311. <w:t>${commonDictionary.cDataType} </w:t>
  312. </w:r>
  313. </w:p>
  314. </w:tc>
  315. <w:tc>
  316. <w:tcPr>
  317. <w:tcW w:w="1218" w:type="dxa"/>
  318. <w:textDirection w:val="lrTb"/>
  319. <w:vAlign w:val="top"/>
  320. </w:tcPr>
  321. <w:p>
  322. <w:pPr>
  323. <w:rPr>
  324. <w:rFonts w:hint="eastAsia"/>
  325. <w:vertAlign w:val="baseline"/>
  326. <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
  327. </w:rPr>
  328. </w:pPr>
  329. <w:r>
  330. <w:rPr>
  331. <w:rFonts w:hint="eastAsia"/>
  332. <w:vertAlign w:val="baseline"/>
  333. <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
  334. </w:rPr>
  335. <w:t>${commonDictionary.cLength} </w:t>
  336. </w:r>
  337. </w:p>
  338. </w:tc>
  339. <w:tc>
  340. <w:tcPr>
  341. <w:tcW w:w="1218" w:type="dxa"/>
  342. <w:textDirection w:val="lrTb"/>
  343. <w:vAlign w:val="top"/>
  344. </w:tcPr>
  345. <w:p>
  346. <w:pPr>
  347. <w:rPr>
  348. <w:rFonts w:hint="eastAsia"/>
  349. <w:vertAlign w:val="baseline"/>
  350. <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
  351. </w:rPr>
  352. </w:pPr>
  353. <w:r>
  354. <w:rPr>
  355. <w:rFonts w:hint="eastAsia"/>
  356. <w:vertAlign w:val="baseline"/>
  357. <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
  358. </w:rPr>
  359. <w:t>${commonDictionary.primaryKey} </w:t>
  360. </w:r>
  361. </w:p>
  362. </w:tc>
  363. </w:tr>
  364. </#list>
  365. </w:tbl>
  366. <w:p>
  367. <w:pPr>
  368. <w:rPr>
  369. <w:rFonts w:hint="eastAsia"/>
  370. <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
  371. </w:rPr>
  372. </w:pPr>
  373. </w:p>
  374. <w:sectPr>
  375. <w:pgSz w:w="11906" w:h="16838"/>
  376. <w:pgMar w:top="1440" w:right="1800" w:bottom="1440" w:left="1800" w:header="851" w:footer="992" w:gutter="0"/>
  377. <w:cols w:space="425" w:num="1"/>
  378. <w:docGrid w:type="lines" w:linePitch="312" w:charSpace="0"/>
  379. </w:sectPr>
  380. </#list>
  381. </w:body>
推荐使用foxe进行编辑,第一层list标签放入 <w:body>下

 
 
  1. <w:body>
  2. <#list listmap as maps>
第二层list标签根据需要放到<w:tr>上这样就可以循环输出各个表的结构了,最后找到闭合标签放入</#list>,这样就可以实现循环了,注意:<w:tr>的闭合标签。

  
  
  1. <#list maps.commonDictionaries as commonDictionary>
  2. <w:tr>
文档输出入下图所示:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值