Java-Web-Office-文档在线编辑_第1页
Java-Web-Office-文档在线编辑_第2页
免费预览已结束,剩余5页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Java WebOffice 文档在线编辑燕飞出品Java WebOffice 文档在线编辑1 创建页面fun cti onShowToolbars()var x = document.all.OA1.GetToolbarslsShow();document.all.OA1.ShowToolbars( !x);if (document.all.OA1.lsOpen()docume nt.all.OA1.Pri nt(); fun cti onDocIsDirty()fun ctionPrintFile()vhtml vhead meta http-equiv=C onten t-Type Of

2、fice 在线编辑 vscript lan guage =javascriptfun cti onCreateDoc()docume nt.all.OA1.CreateNew(fun cti onCreateExcel()docume nt.all.OA1.CreateNew(fun ction CreatePPT()docume nt.all.OA1.CreateNew(fun cti onOpenF romLocal()document.all.OA1.OpenLocalDialog();content =text/html; charset=utf-8Word.DocumExcel.Sh

3、eet );PowerPoi nt.Slide);Java WebOffice 文档在线编辑燕飞出品if (document.all.OAl.lsOpen()if (document.all.OA1.lsDirty()win dow.alert( The file has bee n modified!);elsewin dow.alert( The file has nt bee n modified!);fun cti on SaveAs()docume nt.all.OA1.SaveLocalDialog();fun cti on CloseFile()if (document.all.

4、OA1.lsOpen()docume nt.all.OA1.Close();fun cti onOpenF romServer()var sPath= mpt(服务器文件路径:,16:6888/msbb/tmp/office/test.doc);docume nt.all.OA1.Ope nWebFile(sPath)fun cti on SavetoServer()if (document.all.OA1.lsOpen()window.alert(保存文件到服务器!”);docume nt.all.OA1.SaveWebFile(http

5、:/16:6888/msbb/UpLoadServletobject classid =clsid:18A295DA-088E-42D1-BE31-5028D7F9B9B5id =OA1 widthheight =700);=100%Java WebOffice 文档在线编辑燕飞出品codebase= 16:6888/msbb/tmp/office/OA.CAB#3,1,0,42、创建文件保存到服务器 Servletpackage tmp;import java.io.Bufferedl nputStream;import java.io

6、.BufferedOutputStream;import java.io.File;import java.io.FileOutputStream;import java.i o.IO Excepti on;import java.i o.ln putStream;import java.util.UUID;Java WebOffice 文档在线编辑燕飞出品import javax.servlet.ServletExceptio n; import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletReque

7、st;import javax.servlet.http.HttpServletResp on se;import logi n.Con sta nts;import mon s.fileupload.servlet.ServletFileUpload;import mon s.fileupload.util.Streams;public class UpLoadServlet exte nds HttpServletpublic void in it() throws ServletExceptio npublic void service(HttpServletRequest req, H

8、ttpServletResp onse resp) throws ServletExcepti on, I OExcepti on/ processFileUpload(req, resp); processFileUpload(req);public void processFileUpload(HttpServletRequest request) throws IOExcepti on/读取控件输入流In putStream stream = request.get In putStream();/将输入流保存到文件FileOutputStream savefile = new File

9、OutputStream(Constants.FILEPA TH + UUID.randomUUID() + .doc);byte bytes = new byte1024;int len;while (le n = stream.read(bytes) != -1)savefile.write(bytes, 0, le n);savefile.flush();/关闭文件stream.close();/关闭输入流savefile.close();public void processFileUpload(HttpServletRequest request, HttpServletResp o

10、nse resp on se) throws IOExcepti onServletFileUpload upload = new ServletFileUpload();In putStream stream = n ull;BufferedI nputStream bis = nu II;BufferedOutputStream bos = n ull;tryJava WebOffice 文档在线编辑燕飞出品stream = request.getl nputStream();String file name = ddd.doc;Stri ng fileId = UUID.ra ndomU

11、UID().toStri ng() + file name.substri ng(file name.lastl ndexOf(.); bis =new BufferedI nputStream(stream);bos = new BufferedOutputStream( new FileOutputStream( new File(Co nsta nts.FILEPATH + fileId);Streams.copy(bis, bos, true);resp on se.getWriter().write(success:true); catch (Excepti on e)resp on

12、 se.getWriter().write(Stri ng.format(success:false,message:%s, e.getMessage(); fin allyif (stream != n ull)trystream.close(); catch (Excepti on e)if (bis != n ull)trybis.close(); catch (Excepti on e)if (bos != n ull)trybos.close(); catch (Excepti on e)取扩展名Java WebOffice 文档在线编辑燕飞出品public void destroy()Java WebOffice 文档在线编辑燕飞出品3、配置 web.xmlvservlet-mapp ingv/ servlet-mapping 4、下载控件包Offic

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论