grails - Grails-阅读,自定义和附加Word文档

标签 grails ms-word doc

我需要执行以下操作(使用Grails):

  1. Read a word template
  2. Add user details (e.g. name, last name) to the document
  3. Send the customized word by mail


我想在Apache POI中阅读.doc,然后在文档中输入关键字,例如“°!”#$”并进行自定义。
然后,我将创建文档,将其发送(带有Grails插件)并从服务器中删除该文档

这是一个好方法还是我忘记了什么?
非常感谢你

编辑:
DOCx4j:我的docx操作很简单,因此我可以使用变量replace中的“方法1”,
但由于某种原因,下一个示例对我不起作用:
https://github.com/plutext/docx4j/blob/master/src/samples/docx4j/org/docx4j/samples/VariableReplace.java

我得到:
| Error 2014-03-27 09:10:23,640 [http-bio-9000-exec-5] ERROR errors.GrailsExceptionResolver  - SAXParseException occurred when processing request: [POST] /Estrategia/pasantiaCorta/generarDocumento
Content is not allowed in prolog.. Stacktrace follows:
Message: Content is not allowed in prolog.

在该行中:

//方法1(从3.0.0开始;如果尚未引起解码,则速度更快):
documentPart.variableReplace(mappings);

最佳答案

当然,您可以使用POI或docx4j。无论哪种方式,使用docx都会比使用传统的二进制doc格式更好。

对于docx4j(我的项目),请参见creating-word-docx-documents-dynamically-from-grails

在第2步(添加用户详细信息)时,可以使用variety of approaches

关于grails - Grails-阅读,自定义和附加Word文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22620735/

相关文章:

pdf到word转换显示垃圾内容

Grails spring-security-oauth-google : how to set up

grails - 如何设置Grails代理有错误和Grails安装

grails - Grails禁用域类变量的 View 生成

java - 我如何在 Grails 中生成数据库表?

excel - VBA Excel/Word 查找和替换

java - 使用java将docx转换为doc

java - 在 .NET 和 Java 中将 Word 文档的第一页呈现为图像

java - 如何使用 Java 编辑 MS Word 文档?

Android 如何打开一个.doc 扩展名的文件?