首先,了解下freemarker导出word的流程: 参考https://www.cnblogs.com/llfy/p/9303208.html 异常一: freemarker.core.ParseException: Encountered "<" at line 3, column 3011 in niuwode.ftl.Was expecting one of: <STRING_LITERAL> ... <RAW_STRING> ...
思路解说 word 模板文件(doc 或 docx 文件)另存为 xml 文件 将后缀 xml 改成 html:大部分文档会改成 ftl(FreeMarker 的后缀名),因为 word 文件另存为 xml 文件后,xml 文件中的代码很乱,后面的修改会很麻烦,因为我习惯用 VSCode 编辑器,安装 Beautify 插件后,可以自动格式化 html 代码,这样有利于后面的修改 将内容用${param}替换:例:姓名:月牙坠-->姓名:${name} word 文件中的图片是 Base64 编