Dsoframer控件实现office在线编辑

代码 


Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->  实现方法如下:

   1、下载控件并添加到工具箱中。

   2、页面实现方法

<%@ Page Language="C#" AutoEventWireup="true" Codebehind="WebForm1.aspx.cs" Inherits="zzuoa.web.dsoframer.WebForm1" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>无标题页</title>

    <script language="javascript" type="text/javascript">
    function openword()
    {

    document.all.FramerControl1.Open("http://localhost:2473/web/DownFile/1.doc",false,"Word.Document");
    }

function SaveDoc() {
            var returnValue;     // 保存页面的返回值
            document.all.FramerControl1.HttpInit(); // 初始化Http引擎
            // 添加相应的Post元素
            document.all.FramerControl1.HttpAddPostString("11", "22");
            // 添加上传文件
            document.all.FramerControl1.HttpAddPostCurrFile("Filedate ", "");
            // 提交上传文件
            returnValue = document.all.FramerControl1.HttpPost("../dsoframer/saveword.aspx");
            if ("true" == returnValue) {
                alert("文件上传成功");
            } else {
                alert("文件上传成功")
            }
        }
        function FramerControl1_BeforeDocumentSaved() {
            if (confirm("是否保存到服务器")) {
                SaveDoc();
             }

        }
    </script>

    <script language="javascript" for="FramerControl1" event="BeforeDocumentSaved">
<!--
FramerControl1_BeforeDocumentSaved()
//-->
    </script>

</head>
<body οnlοad="openword();">
    <form id="Form1" method="post" enctype="multipart/form-data" runat="server">
        <div>
            <object id="FramerControl1" codebase="dsoframer.cab" height="100%" width="99%" classid="clsid:00460182-9E5E-11D5-B7C8-B8269041DD57"
                lang="chn">
                <param name="BorderStyle" value="1">
                <param name="TitlebarColor" value="52479">
                <param name="TitlebarTextColor" value="0">
                <param name="Menubar" value="1">
            </object>
        </div>
    </form>
</body>
</html>
saveword.aspx页面后台代码实现保存word到服务器

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;

using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Text;
namespace zzuoa.web.dsoframer
{
    public partial class saveword : System.Web.UI.Page
    {
     

        protected void Page_Load(object sender, EventArgs e)
        {

            BinaryReader bReader = new BinaryReader(Request.InputStream);
            string strTemp = Encoding.GetEncoding("iso-8859-1").GetString(
            bReader.ReadBytes((int)bReader.BaseStream.Length), 0, (int)bReader.BaseStream.Length);
            string match = "Content-Type: application/msword\r\n\r\n";
            int pos = strTemp.IndexOf(match) + match.Length;
            bReader.BaseStream.Seek(pos, SeekOrigin.Begin);

            string newFile = Server.MapPath("~/web/DownFile/1.doc");
            FileStream newDoc = new FileStream(newFile, FileMode.Create, FileAccess.Write);
            BinaryWriter bWriter = new BinaryWriter(newDoc);
            bWriter.BaseStream.Seek(0, SeekOrigin.End);


            while (bReader.BaseStream.Position < bReader.BaseStream.Length - 38)
                bWriter.Write(bReader.ReadByte());

            bReader.Close();
            bWriter.Flush();
            bWriter.Close();

        }
    }
}

有关于dsoframer组件的文章,写了组件的一些api函数,可以查询。

原文地址:http://hi.baidu.com/fdsfsd%B1%F9%D3%EA/blog/item/f86fb533a4ebe695a8018e53.html

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值