向 ms word 添加内容,包括宏
我有一个 JSP 文件,通过设置 content-type
关键字将数据库中的所有数据刷新到 MS-Word 文档中。
我需要将页眉和页脚添加到同一文档中。如果不使用像 POI 这样的 API,我无法从 JSP 中找到直接的方法。所以我创建了一个在本地运行的宏。
如何将其添加到动态生成的 Word 文件中?
I have a JSP file to flush all data from database into a MS-Word document by setting the content-type
keyword.
I need to add header and footer to the same document. I couldn't find a direct way from JSP without using APIs like POI. So I created a macro which works locally.
How do I add this to a dynamically generated Word file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在使用 POI 和 Excel 时也遇到了类似的问题。
解决方案是手动创建一个包含宏的模板 .doc 文件。然后在您的代码中加载该文档,用您的数据修改它,然后保存它。宏将从模板文档中保留。
I had a similar problem with POI and Excel.
The solution is to manually create a template .doc file, with the macro present. Then in your code, load that document, amend it with your data, and save it. The macro will be preserved from the template document.
我将使用 POI 或 docx4j 在服务器上创建 docx 文件,并添加页眉/页脚作为该过程的一部分。
I'd use POI or docx4j to create a docx file on the server, and add the header/footer as part of that process.