zoukankan      html  css  js  c++  java
  • DSOFramer的使用(二)

    1、前面页加载DSOFramer

    <head id="Head1" runat="server">
    <script src="../Scripts/jsRequest.js" type="text/javascript"></script>
    <title>无标题页</title>

    <script language="javascript" type="text/javascript">
    function openWord() {
    var url = jsRequest("url");
    setTimeout(function () { document.all.FramerControl1.Open(url, false, "Word.Document"); }, 1000);
    }

    function SaveDoc() {
    var returnValue; // 保存页面的返回值
    document.all.FramerControl1.HttpInit(); // 初始化Http引擎
    // 添加相应的Post元素
    document.all.FramerControl1.HttpAddPostString("11", "22");
    // 添加上传文件
    document.all.FramerControl1.HttpAddPostCurrFile("Filedate ", "");
    // 提交上传文件

    var url = jsRequest("url");
    url = url.substring(7);
    var Arr = url.split("/");
    url = Arr[0];
    url += "/Online/SaveWord.aspx";

    var filePath = "?filePath=../";
    for (i = 1; i < Arr.length; i++) {
    filePath += Arr[i];
    if (i < Arr.length - 1)
    filePath += "/";
    }
    url += filePath;
    url = "http://" + url;

    //returnValue = document.all.FramerControl1.HttpPost("http://localhost:4468/MTask/Online/saveword.aspx?filePath=path");
    returnValue = document.all.FramerControl1.HttpPost(url);
    }

    function FramerControl1_BeforeDocumentSaved() {
    if (confirm("您确认要保存吗?")) {
    SaveDoc();
    }
    }
    </script>

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

    </head>
    <body onload="openWord();" style="background-color:#C6D4E4">
    <form id="Form1" method="post" runat="server">
    <object id="FramerControl1" name = "MyOffice" style="LEFT: 0px; WIDTH: 1055px; TOP: 0px; right:0px; HEIGHT: 560px" classid="clsid:00460182-9E5E-11D5-B7C8-B8269041DD57" />
    </form>
    </body>

    2、word文件修改后上传至服务器

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.IO;
    using System.Text;

    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 filePath = Request.QueryString["filePath"].ToString();
    string newFile = Server.MapPath(filePath);
    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();

    }
    }





  • 相关阅读:
    warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
    Windows10+CLion+OpenCV4.5.2开发环境搭建
    Android解决部分机型WebView播放视频全屏按钮灰色无法点击、点击全屏白屏无法播放等问题
    MediaCodec.configure Picture Width(1080) or Height(2163) invalid, should N*2
    tesseract
    Caer -- a friendly API wrapper for OpenCV
    Integrating OpenCV python tool into one SKlearn MNIST example for supporting prediction
    Integrating Hub with one sklearn mnist example
    What is WSGI (Web Server Gateway Interface)?
    Hub --- 机器学习燃料(数据)的仓库
  • 原文地址:https://www.cnblogs.com/easypass/p/2434646.html
Copyright © 2011-2022 走看看