在Java中怎么实现在线编辑Word

Python019

在Java中怎么实现在线编辑Word,第1张

需求是在Java中处理Word文档还是要在网页中在线编辑文档?

如果是用Java处理Word文档,我记得有个库是Apache POI,功能还是蛮强大的。

如果要网页端在线编辑Word文档,推荐使用桐享EaaS,有SDK的。客户端无需安装Word,也无需安装插件。对用户来说非常方便,只要一个浏览器就可以了。

ava的一次编译到处运行是说,编译好的可执行程序,只要将它放到装有JVM的机器上就可以运行,你要在你的C,D,F盘的任何目录下都能javac...,java...哪就要保证这些地方有*.java文件和*.java文件所编译的*.class文件,你在DOC下只要找到相应的路劲就可以了,当然首先你是按了JVM的

可以用第三方服务接口实现,但安全性要好,文档不能泄露出去

poi里有个ExcelToHtmlConverter 和 WordToHtmlConverter

这是在网上找的一段代码我没试

HWPFDocumentCore wordDocument = WordToHtmlUtils.loadDoc(new FileInputStream("D:\\temp\\seo\\1.doc"))

WordToHtmlConverter wordToHtmlConverter = new WordToHtmlConverter(

DocumentBuilderFactory.newInstance().newDocumentBuilder()

.newDocument())

wordToHtmlConverter.processDocument(wordDocument)

Document htmlDocument = wordToHtmlConverter.getDocument()

ByteArrayOutputStream out = new ByteArrayOutputStream()

DOMSource domSource = new DOMSource(htmlDocument)

StreamResult streamResult = new StreamResult(out)

TransformerFactory tf = TransformerFactory.newInstance()

Transformer serializer = tf.newTransformer()

serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8")

serializer.setOutputProperty(OutputKeys.INDENT, "yes")

serializer.setOutputProperty(OutputKeys.METHOD, "html")

serializer.transform(domSource, streamResult)

out.close()

String result = new String(out.toByteArray())

System.out.println(result)