DsoFramer 保存word 服务端代码

本文介绍了一个客户端代码实现在线Word文档的操作:包括打开文档预览、保存文档和上传文档到服务端。服务端通过处理HTTP请求,接收并保存上传的Word文档。此流程适用于需要在线编辑或分享Word文档的应用场景。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

效果:

客户端代码:


<html >
<head id="Head1"  >
    <title>Word文件浏览</title>
    <script language="javascript" type="text/javascript">
     
      function save_word(){
       document.all.MyOffice.HttpInit();
         document.all.MyOffice.HttpAddPostCurrFile("FileData", "myword.doc");
         var err = document.all.MyOffice.HttpPost("http://10.153.195.111:6600/page/test/svcmain.jsp");
         if (!err)
             alert('保存失败!');
         else
             alert('保存成功!');      
      }
      
      
        function show_word() {  
         
       
           
            document.all.MyOffice.Open("http://10.153.195.111:6600/page/tools/myword.doc", true, "Word.Document");
            //document.all.MyOffice.CreateNew("Word.Document");
            //进入不留痕状态
            document.all.MyOffice.SetTrackRevisions(0);
           
            //所有菜单都不可使用
        document.all.MyOffice.SetMenuDisplay(0);
        
        document.all.MyOffice.ShowView(6);


            //接受当前修订
           // document.all.MyOffice.SetTrackRevisions(4);
           //document.all.MyOffice.close(); //关闭
          
         
        }
    </script>
</head>
<body onload="show_word();">
    <form id="form1"  >
     <div><button onclick="save_word();">保存</button></div>
      <object id="MyOffice"  style="LEFT: 0px; TOP: 0px; width= 480px ;  HEIGHT: 500px; overflow: scroll; overflow-x: hidden;" VIEWASTEXT name="MyOffice" "
          classid="clsid:00460182-9E5E-11D5-B7C8-B8269041DD57"  codebase=dsoframer.ocx#version=2,3,0,1>
         
          <PARAM NAME="_ExtentX" VALUE="24739">
     <PARAM NAME="_ExtentY" VALUE="16166">
     <PARAM NAME="BorderColor" VALUE="-2147483632">
     <PARAM NAME="BackColor" VALUE="-2147483643">
     <PARAM NAME="ForeColor" VALUE="-2147483640">
     <PARAM NAME="TitlebarColor" VALUE="-2147483635">
     <PARAM NAME="TitlebarTextColor" VALUE="-2147483634">
     <PARAM NAME="BorderStyle" VALUE="0">
     <PARAM NAME="Titlebar" VALUE="0">
     <PARAM NAME="Toolbars" VALUE="0">
     <PARAM NAME="Menubar" VALUE="0">
     <param name="Statusbar" value="0">
     <param name="border" value="0">
     <param name="scrollWidth" value="0">
     <param name="MenuBarStyle" value="0">
      </object>
    </form>
</body>
</html>

服务端代码:

<%@ page contentType="text/html; charset=GBK"%>
<%request.setCharacterEncoding("iso-8859-1");%>

<%@ page import="java.io.*"%>

<%

  System.out.println("======begin....");
  
  InputStream in = request.getInputStream();
  
  

        byte inputByte[] = new byte[2048];
  
  File fp = new File("/oboss/test.doc");
     FileOutputStream fout = new FileOutputStream(fp);  

  if ( -1 != in.read(inputByte)){
   String str = new String(inputByte,"iso-8859-1");
  
   int i = str.indexOf("Content-Type: application/msword");
   if( i != -1)
   {
    String strleft = str.substring(i+ "Content-Type: application/msword\r\n\r\n".length());
    fout.write(strleft.getBytes("iso-8859-1")); 
    }
  }
        while ( -1 != in.read(inputByte))
  { 
   fout.write(inputByte);
  }

  
  fout.close();
        in.close();

%>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值