-
2014-08-16 15:04:12
JAVA生成WORD文件的方法目前有以下种:
一种是jacob 但是局限于windows平台 往往许多JAVA程序运行于其他操作系统 在此不讨论该方案。(需要下载jacob.jar以及jacob.dll)
一种是poi,他对excel处理的很好(读和写),poi对word的操作,基本上处在读word模板阶段,对于写word文件就更弱项了,特别是word上画表格等复杂操作。
还有就是itext,用它生成rtf文件并保存格式为word ;(itext主要是用来生成pdf的文档)
iText-1.2.7.jar和支持rtf的iText-rtf-2.1.7.jar这两个貌似对了,其实还有一个包是比较重要的iTextAsian.jar这个包对于设置字体什么的起了关键作用上网可以搜到的.
- package com.rye.test;
- import java.awt.Color;
- import java.io.FileNotFoundException;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import com.lowagie.text.Cell;
- import com.lowagie.text.Document;
- import com.lowagie.text.DocumentException;
- import com.lowagie.text.Font;
- import com.lowagie.text.PageSize;
- import com.lowagie.text.Paragraph;
- import com.lowagie.text.Table;
- import com.lowagie.text.rtf.RtfWriter2;
- /**
- * 创建word文档 步骤:
- * 1,建立文档
- * 2,创建一个书写器
- * 3,打开文档
- * 4,向文档中写入数据
- * 5,关闭文档
- */
- public class WordDemo {
- public WordDemo() {
- }
- /**
- * @param args
- */
- public static void main(String[] args) {
- // 创建word文档,并设置纸张的大小
- Document document = new Document(PageSize.A4);
- try {
- RtfWriter2.getInstance(document,
- new FileOutputStream("E:/word.doc"));
- document.open();
- //设置合同头
- Paragraph ph = new Paragraph();
- Font f = new Font();
- Paragraph p = new Paragraph("出口合同",
- new Font(Font.NORMAL, 18, Font.BOLDITALIC, new Color(0, 0, 0)) );
- p.setAlignment(1);
- document.add(p);
- ph.setFont(f);
- // 设置中文字体
- // BaseFont bfFont =
- // BaseFont.createFont("STSongStd-Light",
- "UniGB-UCS2-H",BaseFont.NOT_EMBEDDED);
- // Font chinaFont = new Font();
- /*
- * 创建有三列的表格
- */
- Table table = new Table(4);
- document.add(new Paragraph("生成表格"));
- table.setBorderWidth(1);
- table.setBorderColor(Color.BLACK);
- table.setPadding(0);
- table.setSpacing(0);
- /*
- * 添加表头的元素
- */
- Cell cell = new Cell("表头");//单元格
- cell.setHeader(true);
- cell.setColspan(3);//设置表格为三列
- cell.setRowspan(3);//设置表格为三行
- table.addCell(cell);
- table.endHeaders();// 表头结束
- // 表格的主体
- cell = new Cell("Example cell 2");
- cell.setRowspan(2);//当前单元格占两行,纵向跨度
- table.addCell(cell);
- table.addCell("1,1");
- table.addCell("1,2");
- table.addCell("1,3");
- table.addCell("1,4");
- table.addCell("1,5");
- table.addCell(new Paragraph("用java生成的表格1"));
- table.addCell(new Paragraph("用java生成的表格2"));
- table.addCell(new Paragraph("用java生成的表格3"));
- table.addCell(new Paragraph("用java生成的表格4"));
- document.add(new Paragraph("用java生成word文件"));
- document.add(table);
- document.close();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (DocumentException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
代码2:
- <span style="">import java.awt.Color;
- import java.io.FileNotFoundException;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import com.lowagie.text.Cell;
- import com.lowagie.text.Document;
- import com.lowagie.text.DocumentException;
- import com.lowagie.text.Element;
- import com.lowagie.text.Font;
- import com.lowagie.text.PageSize;
- import com.lowagie.text.Paragraph;
- import com.lowagie.text.Table;
- import com.lowagie.text.pdf.BaseFont;
- import com.lowagie.text.rtf.RtfWriter2;
- public class CreateWordDemo {
- public void createDocContext(String file,String contextString)throws DocumentException, IOException{
- //设置纸张大小
- Document document = new Document(PageSize.A4);
- //建立一个书写器,与document对象关联
- RtfWriter2.getInstance(document, new FileOutputStream(file));
- document.open();
- //设置中文字体
- BaseFont bfChinese = BaseFont.createFont("STSongStd-Light","UniGB-UCS2-H",BaseFont.NOT_EMBEDDED);
- //标题字体风格
- Font titleFont = new Font(bfChinese,12,Font.BOLD);
- //正文字体风格
- Font contextFont = new Font(bfChinese,10,Font.NORMAL);
- Paragraph title = new Paragraph("标题");
- //设置标题格式对齐方式
- title.setAlignment(Element.ALIGN_CENTER);
- title.setFont(titleFont);
- document.add(title);
- Paragraph context = new Paragraph(contextString);
- context.setAlignment(Element.ALIGN_LEFT);
- context.setFont(contextFont);
- //段间距
- context.setSpacingBefore(3);
- //设置第一行空的列数
- context.setFirstLineIndent(20);
- document.add(context);
- //设置Table表格,创建一个三列的表格
- Table table = new Table(3);
- int width[] = {25,25,50};//设置每列宽度比例
- table.setWidths(width);
- table.setWidth(90);//占页面宽度比例
- table.setAlignment(Element.ALIGN_CENTER);//居中
- table.setAlignment(Element.ALIGN_MIDDLE);//垂直居中
- table.setAutoFillEmptyCells(true);//自动填满
- table.setBorderWidth(1);//边框宽度
- //设置表头
- Cell haderCell = new Cell("表格表头");
- haderCell.setHeader(true);
- haderCell.setColspan(3);
- table.addCell(haderCell);
- table.endHeaders();
- Font fontChinese = new Font(bfChinese,12,Font.NORMAL,Color.GREEN);
- Cell cell = new Cell(new Paragraph("这是一个3*3测试表格数据",fontChinese));
- cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
- table.addCell(cell);
- table.addCell(new Cell("#1"));
- table.addCell(new Cell("#2"));
- table.addCell(new Cell("#3"));
- document.add(table);
- document.close();
- }
- public static void main(String[] args) {
- CreateWordDemo word = new CreateWordDemo();
- String file = "test.doc";
- try {
- word.createDocContext(file, "测试iText导出Word文档");
- } catch (DocumentException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }</span>
图片版:
- <span style="font-size: medium;">/**
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- try {
- RTFCreate rtfMain = new RTFCreate();
- rtfMain.createRTFContext(FILE_NAME);
- } catch (FileNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (DocumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- public void createRTFContext(String path) throws DocumentException,
- IOException {
- Document document = new Document(PageSize.A4);
- RtfWriter2.getInstance(document, new FileOutputStream(path));
- document.open();
- // 设置中文字体
- BaseFont bfChinese = BaseFont.createFont("STSongStd-Light",
- "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
- // 标题字体风格
- Font titleFont = new Font(bfChinese, 12, Font.BOLD);
- // 正文字体风格
- Font contextFont = new Font(bfChinese, 10, Font.NORMAL);
- Paragraph title = new Paragraph("标题");
- // 设置标题格式对齐方式
- title.setAlignment(Element.ALIGN_CENTER);
- title.setFont(titleFont);
- document.add(title);
- String contextString = "iText是一个能够快速产生PDF文件的java类库。iText的java类对于那些要产生包含文本,表格,图形的只读文档是很有用的。它的类库尤其与java Servlet有很好的给合。使用iText与PDF能够使你正确的控制Servlet的输出。";
- Paragraph context = new Paragraph(contextString);
- // 正文格式左对齐
- context.setAlignment(Element.ALIGN_LEFT);
- context.setFont(contextFont);
- // 离上一段落(标题)空的行数
- context.setSpacingBefore(20);
- // 设置第一行空的列数
- context.setFirstLineIndent(20);
- document.add(context);
- // //在表格末尾添加图片
- Image png = Image.getInstance("c:/fruit.png");
- document.add(png);
- document.close();
- }
- }
- </span>
更多相关内容 -
java 生成word表格包括表格插入图片
2015-07-23 20:01:56如何用java生成动态word表格,以及在表格中插入图片是一个难题,花了两天时间做出来的,希望对大家有帮助 需要jar包:iText-2.1.7.jar, iText-rtf-2.1.7.jar, iTextAsian.jar和jxl.jar 注意前两个jar包的版本要能... -
JAVA根据数据库表生成word表格文档
2017-06-08 13:34:10JAVA根据数据库表生成word表格文档 -
Java读取Word表格内容
2018-06-09 22:07:28通过Java读取word表格中的内容,将内容存到数据库中,将Word中的图片存到硬盘中 -
Java读取并导出Word中的表格(Excel),导出文件为Excel
2017-10-26 19:31:45Java读取并导出Word中的表格(Excel),导出文件为Excel -
Java freemarker 模板生成word动态表格
2022-04-13 08:41:101、新建一个word文档 2、把调整完的word另存为xml格式: 3、使用文本编辑器打开...5、选定动态生成范围,添加 list 标签 6、java代码 导入依赖 <dependency> <groupId>org.freemarker&l...1、新建一个word文档
2、把调整完的word另存为xml格式:
3、使用文本编辑器打开
4、xml格式化
XML 在线格式化 | 菜鸟工具菜鸟工具-XML 在线格式化..https://c.runoob.com/front-end/710/
5、选定动态生成范围,添加 list 标签
6、java代码
项目结构
导入依赖
<dependency> <groupId>org.freemarker</groupId> <artifactId>freemarker</artifactId> <version>2.3.23</version> </dependency>
generateWord
/** * 使用FreeMarker自动生成Word文档 * * @param dataMap 生成Word文档所需要的数据 * @param fileName 生成Word文档的全路径名称 */ public static void generateWord(Map<String, Object> dataMap, String fileName, String templatePath, String template) throws Exception { // 设置FreeMarker的版本和编码格式 Configuration configuration = new Configuration(new Version("2.3.23")); configuration.setDefaultEncoding("UTF-8"); // 设置FreeMarker生成Word文档所需要的模板的路径 configuration.setDirectoryForTemplateLoading(new File(templatePath)); // 设置FreeMarker生成Word文档所需要的模板 Template t = configuration.getTemplate(template, "UTF-8"); // 创建一个Word文档的输出流 Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(fileName)), "UTF-8")); //FreeMarker使用Word模板和数据生成Word文档 t.process(dataMap, out); out.flush(); out.close(); }
调用
public static void main(String[] args) throws Exception { List<Test> lt=new ArrayList<>(); Test t=new Test(); t.setSeq(1); t.setName("测试01"); t.setDes("测试01说明"); lt.add(t); t=new Test(); t.setSeq(2); t.setName("测试02"); t.setDes("测试02说明"); lt.add(t); t=new Test(); t.setSeq(3); t.setName("测试03"); t.setDes("测试03说明"); lt.add(t); Map<String, Object> params = new HashMap<>(); params.put("TestList", lt); String fileName="test.doc"; generateWord(params, "src/main/resources/temp/" + fileName, "src/main/resources/word/", "TemplateV1.xml"); }
生成效果
-
java使用POI导出word数据以及生成word表格
2019-09-07 20:15:40暑期在杭州实习了两个月,主要是使用vue+SpringMVC进行...在网上搜索了许多方法,了解到要导出word文件,其实办法由很多,如jacob,java2word,FreeMarker,Apatch POI等等。 本文采用的是Apatch POI中的一系列API,它...暑期在杭州实习了两个月,主要是使用vue+SpringMVC进行一个网页开发。
而在开发的过程中,也遇到了比较常见的文件导出问题–以固定格式将数据存储在word、excel等office文件格式中。
在网上搜索了许多方法,了解到要导出word文件,其实办法由很多,如jacob,java2word,FreeMarker,Apatch POI等等。
本文采用的是Apatch POI中的一系列API,它可以操作基于MicroSoft OLE 2 Compound Document Format的各种格式文件,可以通过这些API在Java中读写Excel、Word等文件。原则意义上来讲,POI更适合excel文件格式的导出,格式固定且代码简单。而在使用POI操作word文档时,比较麻烦的一点是.doc文件和.docx文件是不同的,也就是说,需要使用不同的API来操作.doc文件和.docx文件。
一、.doc文件:使用HWPFDocument
1)模板文件
新建word模板文件,并在word文件中设置【标签】。
- 普通数据:一般标签以 ${变量名} 的格式命名,其中 $ 和 {} 一定是英文符号,如 ${project} , ${time}。注意标签名不要重复
- 表格文件:由于表格数据是由多组相同格式的数据组成,在计算机语言中,及由数组组成。其与普通数据不同,无需设置标签,只需要在word文件中新建空白表格,并设置表头即可,系统可以根据相应单元格的位置对表格数据进行设置。
模板文件编辑完成之后,记得将模板文件放在项目中。本项目放在了template文件夹中,当然,放在哪里,在代码中就要使用相应的路径来获取相应的模板文件。
2)文件导出
在第一步中已经使用 ${} 的格式对标签进行了设置,那么在代码中,我们只需要使用给相应的标签设置值即可。具体代码如下:
public boolean Export2GeotechnicalLayeringTable(Map<String, Object> map_data,ArrayList<Map<String, String>> list_data,String templatePath,OutputStream out) { boolean result = false; FileInputStream in = null; HWPFDocument document = null; try { in = new FileInputStream(templatePath); document = new HWPFDocument(in); Range range = document.getRange(); range.replaceText("${project_id}", map_data.get("project_id").toString()); // range.replaceText("${project_name}", map_data.get("project_name").toString()); // range.replaceText("${depth}", map_data.get("depth").toString()); // range.replaceText("${hole_id}", map_data.get("hole_id").toString()); // range.replaceText("${hole_altitude}", map_data.get("hole_altitude").toString()); // range.replaceText("${hole_mileage}", map_data.get("hole_mileage").toString()); // range.replaceText("${endhole_depth}", map_data.get("endhole_depth").toString()); // //写入表格数据 //遍历range范围内的table。 TableIterator tableIter = new TableIterator(range); Table table; TableRow row; while (tableIter.hasNext()) { table = tableIter.next(); int rowNum = table.numRows(); for (int i=0, j=2; i<list_data.size()&&j<rowNum; i++,j++) { row = table.getRow(j); row.getCell(0).insertBefore(list_data.get(i).get("layer_id")); row.getCell(1).insertBefore(list_data.get(i).get("start_depth")); row.getCell(2).insertBefore(list_data.get(i).get("end_depth")); row.getCell(3).insertBefore(list_data.get(i).get("geotechnical_name")); row.getCell(4).insertBefore(list_data.get(i).get("geotechnical_description")); row.getCell(5).insertBefore(list_data.get(i).get("sample_id")); row.getCell(6).insertBefore(list_data.get(i).get("sample_depth")); } } document.write(out); out.close(); }catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return result; }
其中map_data中存储的是普通数据,而list_data中存储的是要生成word表格的数组数据。
由于代码都是较简单的java代码,这里不做解释。
代码封装好之后,进行单元测试:public void testTestWord() throws FileNotFoundException { WordUtils wordUtils = new WordUtils(); String templatePath = "D:\\Program Files\\eclipse\\.metadata\\.plugins\\org.eclipse.wst.server.core\\tmp0\\wtpwebapps\\ZJICInformationManagement\\"+"template/钻孔岩土分层表模板.doc"; Map<String, Object> map_data = new HashMap<>(); map_data.put("project_id", "2019.21"); map_data.put("project_name", "ZJIC"); map_data.put("depth", "10.22"); map_data.put("hole_id", "ZKS12"); map_data.put("hole_altitude", "100"); map_data.put("hole_mileage", "23.21"); map_data.put("endhole_depth", "43"); ArrayList<Map<String, String>> list_data = new ArrayList<>(); Map<String, String> temp = new HashMap<>(); for(int i=0;i<10;i++){ temp = new HashMap<>(); temp.put("layer_id", i+""); temp.put("start_depth", "start_depth"); temp.put("end_depth", "end_depth"); temp.put("geotechnical_name", "geotechnical_name"); temp.put("geotechnical_description", "geotechnical_description"); temp.put("sample_id", "sample_id"); temp.put("sample_depth", "sample_depth"); list_data.add(temp); } File file = new File("d:\\word\\test.doc"); FileOutputStream out = new FileOutputStream(file); wordUtils.Export2GeotechnicalLayeringTable(map_data, list_data, templatePath, out); }
最后生成的文件路径为:d:\word\test.doc。
二、.docx文件:使用XWPFDocument
遇到的巨大的坑!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
XWPFDocument比HWPFDocument灵活,但是在生成word文件过程中,对于普通的数据,前者与后者一样,同样通过设置标签来进行导出。但是操作标签的方式不同,XWPFDocument可以读取段落中的所有字符,然后通过XWPFRun(文本对象),使用正则表达式对文本中的标签进行提取,然后设置标签的值…但是在获取标签(正则表达式匹配)的过程中,总是出现中断。如${project},系统会将该标签分为两个字符串 ${ 和 project} ,导致无法与正则表达式匹配,系统判断该段文本并不是标签,导致判断错误。暂时未找到该问题的解决办法。网上说是因为使用了中文的括号 {。需要将标签先使用文本编辑器–记事本等编辑之后,再复制粘贴到word文档中,本人亲测之后,问题未得到解决。
三、结果展示
-
【java】Freemarker 动态生成word(带图片表格)
2021-03-17 22:23:131、添加freemarker.jar 到java项目。2、新建word文档。...5、生成表格,包括动态列和动态行。其中columnList 是List格式的表头数据,datas 是List>格式的全部表格数据。#list>${cell}#lis...1、添加freemarker.jar 到java项目。
2、新建word文档。
3、将文档另存为xml 格式。
4、将xml格式化后打开编辑(最好用notepad,有格式),找到需要替换的内容,将内容换为变量(${变量名})。
5、生成表格,包括动态列和动态行。其中columnList 是List格式的表头数据,datas 是List>格式的全部表格数据。
#list>
${cell}
#list>
#list>
6、生成图片。将xml文件中 中的数据替换成需要的图片的base64编码即可。
7、保存后,将文件后缀改为.ftl,放到java项目文件夹。生成word:
Map map = new HashMap();
map.put("变量名", 变量内容);
public static void createWord(Map map, String filePath) {
try {
Configuration configuration = new Configuration();
configuration.setDefaultEncoding("UTF-8");
configuration.setClassForTemplateLoading(TemplateToWord.class, "/com/cn/templates/");//模板所在文件夹
Template template = configuration.getTemplate("report.ftl");//根据名称加载模板
File outFile = new File(filePath);//生成新word文档
if (!outFile.getParentFile().exists()) {
outFile.getParentFile().mkdirs();
}
Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), "UTF-8"));
// 生成文件
template.process(map, out);
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
-
java动态生成word模版
2018-01-15 17:00:01利用java实现简单动态生成word模版 项目中需要用 java 程序生成doc 文件,百度一番,发现FreeMarker 的评价比较高。 FreeMarker是一个用Java语言编写的模板引擎,它基于模板来生成文本输出,至于想详细了解 ... -
JAVA使用POI-TL生成word表格列宽自定义
2022-02-11 11:06:06JAVA使用POI-TL生成word表格列宽自定义 -
Java动态生成word
2017-05-26 11:38:29使用Java动态生成可编辑的word -
Java Poi流 根据Word模板插入相应的文本、表格和图片,生成新的Word报告
2020-03-12 09:44:54Java Poi流根据Word模板插入相应的文本、表格和图片,并生成新的Word报告。文档提供相应的jar包和Word模板文件,表格支持动态添加数据,插入图片支持多种格式! -
java 动态获取数据库信息生成word(含表格,柱状图),并下载.docx
2019-11-07 14:11:54java 动态获取数据库信息生成word(含表格,柱状图),并下载 -
java根据word模板导出Word文件,插入图片表格都可以
2020-06-12 16:57:03网络上的根据模板填充Word我都看过一些, 它们的功能在数据换行的时候用的是run对象的.addCarriageReturn()方法,或者是直接用\n实现换行。这些都不符合我的需求, 因为我要的是分段,而不是换行。换行的word导致另一... -
Java中利用freemarker模板动态生成word含表格
2021-05-25 21:47:13最近公司有导出word的需求,由于word的样式有的很复杂所以记录一下Java中利用freemarker模板动态生成word含表格,以防以后忘记。 配置 项目的gradle文件,xxx.gradle文件里配置好拷贝ftl文件的代码 (绿色部分... -
JAVA用POI生成Word文档
2017-10-24 14:52:46JAVA使用POI生成Word文档,并带下载功能。使用POI类包 -
java实现word表格指定位置盖章,并且设置印章悬浮于文字之上
2019-11-19 16:14:07java实现word表格指定位置盖章,并且设置印章悬浮于文字之上,达到跟用实体印章在A4纸上盖章一样的效果 -
在word中动态增加表格并写入数据
2016-08-27 21:13:18在word中根据表头动态增加表格行,然后把数据中数据中写入表格中。 -
Java POI导出word文件及生成表格
2020-03-25 17:04:37HWPF是处理 Microsoft Word 97(-2007) .doc文件格式,它还为较旧的Word 6和Word 95文件格式提供了有限的只读支持。包含在poi-scratchpad-XXX.jar中。 XWPF是处理 Word 2007 .docx文件格式,包含在poi-ooxml-XXX.... -
java 动态获取数据库信息生成word(含表格,柱状图),并下载
2018-11-29 09:45:53Springboot Controller中使用service调SQL语句的方法,动态获取数据库信息添加到WORD表格中,检查到的数据绘制为柱形图(直方图)添加到文档中,并生成word(含表格,柱状图)存储到本地,在浏览器下载本地的word文档 -
Java操作Word生成动态表格
2021-02-20 14:01:50Java操作Word生成动态表格 1.需要spire.doc的jar包,有免费的(官网可下载); 2.添加jar包至资源; 3.进行在word中表格操作; 部分代码: 操作生成表格: //创建Document对象 Document doc = new Document(); ... -
Java编程生成word文件设置字体段落格式
2013-01-31 10:14:40Java对PageOffice编程,从空白的word模板动态生成word文件,填充文本内容、图片,同时设置文本的字体、段落、格式。 PageOffice是标准Java组件,标准JSP Tag标签方式引用,完美支持Eclipse、MyEclipse等开发工具。 ... -
RtfTemplate实现Java生成word
2019-03-19 01:37:42NULL 博文链接:https://hnhhshun-126-com.iteye.com/blog/713411 -
Java根据ftl模板生成多表格复杂性word文档
2014-12-09 09:14:06Java根据ftl模板生成多表格复杂性word文档,工程可直接导入eclipse中执行的。 -
Java导出word之POI生成word表格
2020-08-13 14:42:04... import org.apache.poi.xwpf.usermodel.*; import org.openxmlformats.schemas.wordprocessingml.x2006.main.*; import java.io.FileOutputStream; import java.math.BigInteger;...import java.ut -
java代码实现填充word模板生成word合同的实例
2018-02-04 12:05:36对企业合同word模版,可通过java 程序实现生成word文件,然后再通过word转成pdf实现。本实例的方案,可实现模版到word文件的转换。附件有代码和效果图。 -
Java读取Word中的表格(Excel),并导出文件为Excel
2019-11-12 16:28:56Java读取Word中的表格(Excel),并导出文件为Excel -
Java Word模板导出包含表格单元格合并
2021-02-12 18:16:50java通过freemarker导出word循环合并表格单元格本文主要讲解通过freemarker模板引擎来导出word,并且在word中包含表格的合并部分需要循环生成。一、Java需要通过模板导出的word如上图所示。物品的信息是循环部分。... -
SpringBoot_Freemarker生成Word_多个表格+两层嵌套循环
2019-08-01 16:54:40SpringBoot_Freemarker生成Word_多个表格+两层嵌套循环; 步骤说明: 1.用Microsoft Office Word打开word原件;将文档中需要动态生成的内容,替换为属性名 ${name} 2.另存为,选择保存类型Word 2003 XML 文档(*....