使用 JAVA 将 HTML 内容写入 MS WORD?
我正在开发一个使用下标和上标的考试软件.所以我必须将问题以 HTML 格式存储在数据库中,现在我想将这些带有 HTML 标签的问题写到单词中,我尝试使用 Apache POI 库,这是示例文本:
I am developing an Exam Software in which I have used Subscript and superscript. so I have to store the Questions in HTML in the Database, Now i want to write those questions with HTML tags to the word, I tried Using Apache POI Library, here is the sample text :
<html>
<head> </head>
<body><font face="Shruti"> MY QUESTION </font>
</body>
</html>
但是当我尝试使用 apache poi 在 Word Document 中写入文本时,它显示了 HTML 标签
but when I am trying to write text in word Document using apache poi , it is showing the HTML tags
您可以将 HTML 添加为 AltChunk,并在首次打开文件时让 Word 将其转换为原生 docx 内容.
You can add your HTML as an AltChunk, and have Word convert it to native docx content when the file is first opened.
如果您需要在 Java 中转换为原生 docx 内容,您可以使用 docx4j-ImportXHTML一个>
If you need to convert to native docx content in Java, you can use docx4j-ImportXHTML
披露:我管理那个仓库.
Disclosure: I manage that repo.