首页 行业资讯 宠物日常 宠物养护 宠物健康 宠物故事

应用点聚WebOffice在线编辑word怎么解决

发布网友 发布时间:2022-04-24 10:08

我来回答

1个回答

热心网友 时间:2023-10-09 21:50

使用点聚WebOffice在线编辑word
Word编辑页面

  <%@page contentType="text/html;charset=gbk"%> <% String imgpath = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + imgpath; String path = (String) request.getAttribute("filepath"); %> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <SCRIPT LANGUAGE=javascript> <!-- // 初始化控件 function WebOffice1_NotifyCtrlReady() { document.all.WebOffice1.OptionFlag |= 128; document.all.WebOffice1.LoadOriginalFile("<%=basePath%>/getwordstream.jsp filename=C:\\1.doc", "doc"); document.all.WebOffice1.SetToolBarButton2("Standard",1,0); } // 上传文档 function SaveDoc(fname,docType) { try{ var webObj=document.getElementById("WebOffice1"); var returnValue; webObj.HttpInit();//初始化Http引擎 // 添加相应的Post元素 webObj.HttpAddPostString("fname", fname); webObj.HttpAddPostString("DocType",docType); webObj.HttpAddPostCurrFile("DocContent","");// 上传文件 returnValue = webObj.HttpPost("<%=basePath%>/savewordstream.jsp");// 判断上传是否成功 if("succeed" == returnValue){ alert("文件上传成功!");}else if("failed" == returnValue) alert("文件上传失败!"); return_onclick(); }catch(e){ //alert("异常\r\nError:"+e+"\r\nError Code:"+e.number+"\r\nError Des:"+e.description); } } // 事件 function WebOffice1_NotifyWordEvent(eventname) { if(eventname=="DocumentBeforeSave"){ //SaveDoc('C:\\1.doc', 'doc');// 此处不能用,否则无法上传, 不知原因 } } //--> </SCRIPT> <SCRIPT LANGUAGE=javascript FOR=WebOffice1 EVENT=NotifyCtrlReady> <!-- WebOffice1_NotifyCtrlReady(); //--> </SCRIPT> <SCRIPT LANGUAGE=javascript FOR=WebOffice1 EVENT=NotifyWordEvent(eventname)> <!-- WebOffice1_NotifyWordEvent(eventname); //--> </SCRIPT> </head> <body> <input type="button" value="保存" onclick="SaveDoc('C:\\1.doc', 'doc')" /> <!-- 装载Weboffice控件 --> <object id=WebOffice1 height='100%' classid='clsid:E77E049B-23FC-4DB8-B756-60529A35FAD5' codebase='<%=imgpath%>/weboffice_v6.0.5.0.cab#Version=6,0,5,0'> <param name='_ExtentX' value='6350'> <param name='_ExtentY' value='6350'> </object> <!-- 结束装载代码 --> </body> </html>

获取word文件流jsp

  <%@page contentType="text/html;charset=gbk"%> <%@page import="java.io.BufferedInputStream"%> <%@page import="java.io.FileInputStream"%> <% String filename = request.getParameter("filename"); filename = new String(filename.getBytes("iso-8859-1"), "utf-8"); try { BufferedInputStream in = new BufferedInputStream( new FileInputStream(filename)); java.io.OutputStream outStream = response.getOutputStream(); byte[] buf = new byte[1024]; int bytes = 0; while ((bytes = in.read(buf)) != -1) outStream.write(buf, 0, bytes); in.close(); outStream.close(); } catch (Exception e) { out.println(e.toString()); } %>

保存word文件流jsp

  <%@ page contentType="text/html;charset=GB2312"%> <%@ page import="java.io.*"%> <jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" /> <% try { // 初始化上传组件 mySmartUpload.initialize(pageContext); mySmartUpload.upload(); // 获取传到表单记录 String name = mySmartUpload.getRequest().getParameter("fname"); com.jspsmart.upload.File myFile = null; myFile = mySmartUpload.getFiles().getFile(0); if (!myFile.isMissing()) { java.io.File tfile = new java.io.File(name); if (tfile.exists()) { tfile.delete(); } myFile.saveAs(name, mySmartUpload.SAVE_PHYSICAL); // 保存上传文件 out.clear(); out.write("succeed");//返回控件HttpPost()方法值。 out.flush(); } else throw new Exception("File is missing!!"); } catch (Exception e) { out.clear(); out.write("failed");//返回控件HttpPost()方法值。 out.flush(); } %>

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com