Web Office控件的使用
效果图:
代码
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>_编辑页</title>
<script type="text/javascript" src="../js/OfficeServerServlet/WordDoc.js"></script>
<script language="javascript" type="text/javascript">
var resID="E320CA2D327462BF207B604AA5CAD52C";
var docMode = 'add';
var operate = "view";
var path = "";
var serverName = "localhost";
var serverPort = "5543";
</script>
</head>
<body onload="WordDocNew(docMode,resID,'系统管理员',serverName,serverPort,path,operate);AttachInit()">
<table cellspacing="1" cellpadding="4" class="border">
<tr class="titletdbg">
<td colspan="8">正文 <br />
<button name="insertB" class="button" onclick="DoInsert();" >粘贴文件</button>
<script type="text/javascript" src="../js/OfficeServerServlet/CreateOffice.js"></script>
<script language="javascript">
//控件显示宽度强行设置为100%,与表单对齐
showOffice(serverName,serverPort,path,"600");
//此处必须这样生成控件,新的IE不会自动激活控件.这是由于Microsoft的版权问题导致.具体可参考MSDN
</script>
</td>
</tr>
<tr class="titletdbg">
<td colspan="8"><font color=red>如果你的浏览器未正常显示控件,请</font><a href="../js/OfficeServerServlet/officeSetup.exe">下载office控件</a>查看软件安装。 </td>
</tr>
<tr class="titletdbg">
<td colspan="8">
<script language="javascript">
function AttachInit(){
var attachCtrl = document.getElementById("attachCtrl");
if(attachCtrl == null || typeof(attachCtrl) == "undefined") alert("请确保正确安装附件控件");
attachCtrl.ServerName = serverName; //服务器
attachCtrl.ServerPort = serverPort; //服务器端口
attachCtrl.ServerPath = path + "/OfficeServerServlet"; //程序地址
attachCtrl.DBName = "syoa"; //当前数据库路径
attachCtrl.DocID = "D:/tmocat/tomcat-7010/f"+"\\oa"; //主文档UNID
attachCtrl.UserName = "系统管理员"; //当前用户名(中文简称)
//attachCtrl.EditMode = true; //控制可否在线编辑
//attachCtrl.CanSave = true;
attachCtrl.BaseDownUrl = "D:/tmocat/tomcat-7010/f"+"\\oa"; //主文档UNID
attachCtrl.FileName = "";
attachCtrl.FileSize = "";
attachCtrl.FileDate = "";
//attachCtrl.EditType = false;
var attach = attachCtrl.InitFileList();
}
</script>
<script src="../js/OfficeServerServlet/CreateOfficeAttach.js" > </script>
<script language="javascript">
//document.write('');
//控件显示宽度强行设置为100%,与表单对齐
showOfficeAttach(serverName,serverPort,'','150');
</script>
</td>
</tr>
</table>