office在线编辑和远程保存的实现
在网上查询了很久,没有一个给出真正可用源代码的,经过艰苦努力,终于实现了在线编辑office文档。如果再增加一些控制,即可实现OA系统的文档流转、在线编辑审阅。
并发控制采用审阅人锁定记录,同时兼顾版本控制(未在本文中)。
当然需要先下载一个DSOFRAMER.ocx控件,其它控件要收费也不一定好用。
主界面可以用datalist显示数据库,点击打开时调用以下程序。
//office.aspx如下
<%@ Page language="C#" ContentType="text/html" CodeFile="office.aspx.cs" Inherits="_office" Debug="true" ResponseEncoding="gb2312" %>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
.STYLE1 {
font-family: "宋体";
font-size: 11px;
}
-->
</style>
<head>
<title>在线编辑</title>
<script language="javascript" type="text/javascript">
<!--
function show_word() {
window.opener.location=window.opener.location; //刷新父页面,因为修改了锁定人,在父页面中能正常显示
var url1=window.location.host+":"+window.location.port; //返回主机和端口
var id = "http://"+url1+"/oa/dso/Getdc.aspx?id=<%=giveinfoback()%>" ; //打开地址,通过后台ASP函数传值数据库查询关键字,
document.all.MyOffice.Open( id,false, "<%=givelxback()%>");
//<%=givelxback()%>返回文件类型 如"Excel.Sheet","PowerPoint.Show";
}
function Submit_upload_onclick() {
document.all.MyOffice.HttpInit();
document.all.MyOffice.HttpAddPostCurrFile("File", "");
var url1=window.location.host+":"+window.location.port; //返回主机和端口
var id = "