1.用java怎么实现对word的在线编辑
Office在线编辑比较复杂,知道的方案有几种。
1)采用网页插件,比如PageOffice,这种方案实际是调用本地Office进行编辑,确切的说是网页编辑而非在线编辑。2)采用微软的OWA,这个是网页版的Office,好处确实是原生的Office,缺点是网页版功能比本地版本弱,开发难以得到微软的支持,坑很多,碰到了也不知道怎么解决。
与之接近的是一起写,石墨这样的类Office编辑,这个就不是原生office格式,是格式转换后的在线编辑,还有就是类word编辑相对完善,而excel,ppt这些就差很多了。3)采用UZER.ME的SDK,UZER.ME支持网页内无插件使用各种原生应用,当然也包括office,本地也无需安装Office,全平台支持。
缺点是需要服务器资源较多。
2.用java怎么实现对word的在线编辑
Office在线编辑比较复杂,知道的方案有几种。
1)采用网页插件,比如PageOffice,这种方案实际是调用本地Office进行编辑,确切的说是网页编辑而非在线编辑。
2)采用微软的OWA,这个是网页版的Office,好处确实是原生的Office,缺点是网页版功能比本地版本弱,开发难以得到微软的支持,坑很多,碰到了也不知道怎么解决。
与之接近的是一起写,石墨这样的类Office编辑,这个就不是原生office格式,是格式转换后的在线编辑,还有就是类word编辑相对完善,而excel,ppt这些就差很多了。
3)采用UZER.ME的SDK,UZER.ME支持网页内无插件使用各种原生应用,当然也包括office,本地也无需安装Office,全平台支持。缺点是需要服务器资源较多。
3.Java中怎么实现浏览器在线编辑Office文档
可以用第三方服务接口实现,但安全性要好,文档不能泄露出去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);。
4.Java如何操作Word?Java如何操作Word,Excel,
Java Excel API 文档 /jexcelapi/ 1、一个jacob操作Word的例子,其他操作excel,pdf的sample里都有 import java。
io。File; import com。
jacob。com。
*; import com。jacob。
activeX。*; public class WordTest { public static void main(String[] args) { WordBean word=new WordBean(); word。
openWord(true); word。createNewDocument(); word。
insertText("Hello word。"); } } import com。
jacob。activeX。
*; import com。 jacob。
com。*; public class WordBean extends java。
awt。Panel { private ActiveXComponent MsWordApp = null; private Dispatch document = null; public WordBean() { super(); } public void openWord(boolean makeVisible) { //Open Word if we've not done it already if (MsWordApp == null) { MsWordApp = new ActiveXComponent("Word。
Application"); } //Set the visible property as required。 Dispatch。
put(MsWordApp, "Visible", new Variant(makeVisible)); } public void createNewDocument() { //Find the Documents collection object maintained by Word Dispatch documents = Dispatch。 get(MsWordApp,"Documents")。
toDispatch(); //Call the Add method of the Documents collection to create //a new document to edit document = Dispatch。 call(documents,"Add")。
toDispatch(); } public void insertText(String textToInsert) { // Get the current selection within Word at the moment。 If // a new document has just been created then this will be at // the top of the new doc Dispatch selection = Dispatch。
get(MsWordApp,"Selection")。toDispatch(); //Put the specified text at the insertion point Dispatch。
put(selection,"Text",textToInsert); } public void saveFileAs(String filename) { Dispatch。 call(document,"SaveAs",filename); } public void printFile() { //Just print the current document to the default printer Dispatch。
call(document,"PrintOut"); } public void closeDocument() { // Close the document without saving changes // 0 = wdDoNotSaveChanges // -1 = wdSaveChanges // -2 = wdPromptToSaveChanges Dispatch。 call(document, "Close", new Variant(0)); document = null; } public void closeWord() { Dispatch。
call(MsWordApp,"Quit"); MsWordApp = null; document = null; } }。
5.javaweb项目怎么实现在线编辑合同宓墓δ
其实就是Word在线编辑吧。
一般来说两种途径。一种是利用插件,比如PageOffice。好处是服务端有一整套的开发接口,劣势是需要安装插件,客户端需要有Word等Office应用程序安装,不同的客户端环境不同可能造成后继使用过程中的维护量。
还有一种是无插件的方式,Office 365就是典型的,不过如果是私有化部署,就不能用Office 365了。
还有一个是uzer.me,能提供无插件的原生Office编辑,提供JS SDK和REST API,各种编程语言都能对接。好处是无插件,劣势是只支持webRTC的浏览器,比如火狐、谷歌,360极速等,反正IE是不支持的(听说最近IE也能支持,但是要装插件了)。
还有一种在线编辑,是采用类似Word的模式,而实际更多是一个富文本的编辑器,这个用HTML就可以实现,有一些开源的工具的。无非是把Word和H5要格式互转。这个可能对于合同来说,容易丢失格式。如果格式是固定的话,会简单一些。
转载请注明出处51数据库 » 在线编辑wordjava