使用来自 java 对象的值从模板动态创建 word 文档 [英] Creating a word document from a template dynamically using values from java objects

查看:34
本文介绍了使用来自 java 对象的值从模板动态创建 word 文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从 HTML 页面创建一个 Word 文档.我计划获取 HTML 页面上的值,然后将这些值传递给文档模板.我使用 JSOUP 来解析 HTML 页面的内容,并在我的 java 程序中获取值.我现在想将这些值传递给 Word 文档模板.我想知道我可以用来创建文档模板并将值传递给模板以创建 Word 文档的最佳技术是什么.

I want to create a word document from an HTML page. I am planning to get the values on the HTML page and then pass these values to a document template. I have used JSOUP to parse the contents of the HTML page and I get the values in my java program. I now want to pass these values to a word document template. I want to know what are the best techniques I can use to create the document template and pass the values to the template to create the word document.

谢谢.

推荐答案

我发现了一些非常有趣和简单的事情.我们只需要为我们要创建的文档创建一个简单的 .xml 模板,然后以编程方式更改 xml 文件的内容并将其保存为 ms word 文档.

I found something very Interesting and simple. We just need to create a simple .xml template for the document we want to create and then programmatically change the contents of the xml file and save it as a ms word document.

您可以在此处找到 xml 模板和代码.

You can find the xml template and the code here.

这篇关于使用来自 java 对象的值从模板动态创建 word 文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆