打开APP
未登录
开通VIP,畅享免费电子书等14项超值服
开通VIP
首页
好书
留言交流
下载APP
联系客服
Weboffice的使用(三)
给力共享
>《源码代码》
2012.04.05
关注
<div id=
"fckeditor"
style=
"POSITION: relative;width:100%;height:460px;OVERFLOW:hidden;display:block"
><!-- 正文 -->
<script type=
"text/javascript"
>
var oFCKeditor =
new
FCKeditor(
'content'
);
oFCKeditor.BasePath =
"fckeditor/"
;
oFCKeditor.Value =
''
;
//oFCKeditor.Config["DefaultLanguage"] = fcklanguage;
//oFCKeditor.FormatSource = false;
//oFCKeditor.FormatOutput = false;
//oFCKeditor.EnableXHTML = false;
//oFCKeditor.EnableSourceXHTML = false;
oFCKeditor.Height =
450
;
oFCKeditor.Width =
'100%'
;
oFCKeditor.Create();
</script>
</div>
<div id=
"iWebOffice"
style=
"POSITION: relative;width:100%;height:460px;OVERFLOW:hidden;display:none"
>
<object id=
"WebOffice"
style=
"POSITION: relative;top:-20"
width=
"100%"
height=
"450px"
classid=
"clsid:8B23EA28-723C-402F-92C4-59BE0E063499"
codebase=
"/vplugin/iWebOffice2006.cab#version=7,5,4,0"
>
<param name=
"WebUrl"
value=
"<%=mServerUrl %>"
>
<param name=
"RecordID"
value=
""
>
<param name=
"Template"
value=
""
>
<param name=
"FileName"
value=
""
>
<param name=
"FileType"
value=
""
>
<param name=
"UserName"
value=
""
>
<param name=
"ExtParam"
value=
""
>
<param name=
"EditType"
value=
"1,1"
>
<param name=
"PenColor"
value=
"#FF0000"
>
<param name=
"PenWidth"
value=
"1"
>
<param name=
"Print"
value=
"1"
>
<param name=
"ShowToolBar"
value=
"0"
>
<param name=
"ShowMenu"
value=
"0"
>
</object>
</div>
function onChangeDocType(docType){
//改变文档类型
var iWebOffice = document.getElementById(
"iWebOffice"
);
var fckeditor = document.getElementById(
"fckeditor"
);
switch
(docType) {
case
2
:
//无正文
iWebOffice.style.display=
'none'
;
fckeditor.style.display=
'none'
;
break
;
case
3
:
//HTML
iWebOffice.style.display=
'none'
;
fckeditor.style.display=
''
;
break
;
case
4
:
//word
initObject(
'4'
,
true
);
iWebOffice.style.display=
''
;
fckeditor.style.display=
'none'
;
break
;
case
5
:
//excel
initObject(
'5'
,
true
);
iWebOffice.style.display=
''
;
fckeditor.style.display=
'none'
;
break
;
case
7
:
//ppt
initObject(
'7'
,
true
);
iWebOffice.style.display=
''
;
fckeditor.style.display=
'none'
;
break
;
default
:
break
;
}
}
/*---------------------------iWebOffice处理---------------------*/
//作用:初始化iWebOffice对象
function initObject(fileType,bCreate){
if
(fileType==
"5"
){
document.WebOffice.FileType =
".xls"
;
}
else
if
(fileType==
"4"
){
document.WebOffice.FileType =
".doc"
;
}
else
if
(fileType==
"7"
){
document.WebOffice.FileType =
".ppt"
;
}
try
{
document.WebOffice.CreateFile();
// document.WebOffice.WebOpen();
}
catch
(e){
}
}
//作用:打开服务器文档
function LoadDocument(){
frm.WebOffice.FileName =
"Test"
;
//frm.WebOffice.FileType = ".doc";
frm.WebOffice.EditType =
"0,1"
;
if
(!frm.WebOffice.WebOpen()){
//打开该文档 交互OfficeServer的OPTION="LOADFILE"
alert(frm.WebOffice.Status);
//显示状态,从OfficeServer中读取
}
else
{
alert(frm.WebOffice.Status);
//显示状态,从OfficeServer中读取
}
}
//作用:保存服务文档
function SaveDocument(){
document.WebOffice.FileName =
"Test"
+document.WebOffice.FileType;
document.WebOffice.WebSave();
}
//作用:打印文档
function WebOpenPrint(){
try
{
VelcroForm.WebOffice.WebOpenPrint();
StatusMsg(VelcroForm.WebOffice.Status);
}
catch
(e){}
}
//作用:页面设置
function WebOpenPageSetup(){
try
{
if
(VelcroForm.WebOffice.FileType==
".doc"
){
VelcroForm.WebOffice.WebObject.Application.Dialogs(
178
).Show();
}
if
(VelcroForm.WebOffice.FileType==
".xls"
){
VelcroForm.WebOffice.WebObject.Application.Dialogs(
7
).Show();
}
}
catch
(e){}
}
//作用:保存office正文到本地
function savelocalFile(){
try
{
document.WebOffice.WebSaveLocalFile();
}
catch
(e){}
}
//作用:打开本地office文件
function openLocalFile(){
try
{
document.WebOffice.WebOpenLocalFile();
}
catch
(e){}
}
属性[Office公共]
Caption 软件编号
WebUrl 提交服务器程序路径
RecordID 需要打开的记录号
Template 需要使用的模版名
FileName 需要打开的文件名
FileType 需要打开的文件类型
EditType 需要使用的方式
UserName 用户名
Status 当前插件状态
Error 错误信息状态
ActiveDocument 文档对象接口
MsgFilepath 当前文件目录
其中:RecordID,Template,FileName,FileType,EditType,UserName是全局参数。可供后台服务器程序使用。
语法: WebUrl
特性: 只写
类型: String
功能: 设置服务器应用程序Url路径
调用: WebOffice.WebUrl=
"http://www.dragongod.com/WebEditor/OfficeServer.asp"
说明: OfficeServer.asp是一个服务器应用服务,用户可以根据自己的情况指定自己的应用程序名
语法: RecordId
特性: 只写
类型: String
功能: 设置文档的纪录号
调用: WebOffice.RecordId=
"324923100"
说明: RecordId是一个文档的唯一标识,通过这个编号,可以在服务器上找到该文档,这个值也可以是其他字符如:
"办公系统解决方案"
语法: Template
特性: 只写
类型: String
功能: 设置模板编号
调用: WebOffice.Template=
"10214563698"
说明: Template是一个模板文档的唯一标识,通过这个模板编号,可以在服务器上找到该模板文档,这个值也可以是其他字符如:
"办公系统解决方案模板"
语法: FileName
特性: 只写
类型: String
功能: 设置文档名称
调用: WebOffice.FileName=
"办公系统解决方案.doc"
说明: FileName是一个文档的扩展属性,通过这个扩展属性,可以在服务器上找到该模板文档,这个值也可以是其他字符如:
"办公系统解决方案模板"
语法: FileType
特性: 只写
类型: String
功能: 设置文档类型
调用: WebOffice.FileType=
".doc"
说明: FileType是一个文档的类型,通过这个类型,决定打开的文档是Word还是Excel
FileType 为 “.doc” 或 “.xls”
语法: EditType
特性: 只写
类型: String
功能: 设置文档打开方式 有两种付值方式:
WebOffice.EditType=”X” ;
X 的含义如下:
“
0
” 只读、且不能拷贝,
“
1
” 起草编辑[可写无痕迹保留] ,
“
2
” 编辑[有痕迹保留]
如果需要有痕迹保留功能,就可以设置为 WebOffice.EditType=”
2
”;
语法: UserName
特性: 只写
类型: String
功能: 设置操作文档用户名
调用: WebOffice.UserName=
"张三"
说明: UserName是一个编辑文档的用户名
语法: Status
特性: 只读
类型: String
功能: 返回当前状态
调用: alert(WebOffice.Status);
语法: Error
特性: 只读
类型: String
功能: 返回当前错误信息
调用: alert(WebOffice.Error);
语法: ActiveDocument
特性: 读写
类型: Object
功能: 返回Word或Excel对象,可用javascript脚本调用VBA对Word,Excel编程
调用: alert(WebOffice.ActiveDocument.Application.UserName) 返回用户名,该用法请参考VBA
如果是Word 文件,ActiveDocument 是Word 的 ActiveDocument对象
如果是Excel 文件,ActiveDocument 是Excel 的ActiveSheet对象
可以通过ActiveDocument.Application得到VBA的Application对象
方法:
LoadFile() 打开网络文档
输入参数 无。
输出参数 返回成功或失败
特别说明 Office公共
SaveFile() 保存网络文档
输入参数 无。
输出参数 返回成功或失败
特别说明 Office公共
Close() 关闭所有文档
输入参数 无。
输出参数 返回成功或失败
特别说明 Office公共
LoadTemplate() 调入网络模板
输入参数 无。
输出参数返回设置成功或失败。
特别说明 Office公共
SaveTemplate() 保存网络模板
输入参数 无。
输出参数返回设置成功或失败。
特别说明 Office公共
UpdateFile() 保存定稿的文档
输入参数 无。
输出参数 返回设置成功或失败。
特别说明 Office公共
GetMsgByName(FieldName) 取得服务器返回信息的值
输入参数:
FieldName 字段域名称
输出参数 返回成功或失败。
特别说明 Office公共
SetMsgByName(FieldName, FieldValue) 设置相应值,等待发送给服务器
输入参数:
FieldName 字段域名称
FieldValue 字段域值
输出参数 无
特别说明 Office公共
MsgTextClear () 清除由SetMsgByName设置的变量
输入参数 无。
输出参数 无。
特别说明 Office公共
MsgFileClear(FileName) 清除通过MsgFileLoad调入或服务器返回的文件
输入参数:
FileName 文件名称
输出参数 无
特别说明 Office公共
MsgFileLoad(FileName) 调入FileName所指定的文件
输入参数:
FileName 文件名称
输出参数 无
特别说明 Office公共
MsgFileSave(FileName) 保存FileName所指定的文件
输入参数:
FileName 文件名称
输出参数 无
特别说明 Office公共
SendToServer() 发送由SetMsgByName设置的值给服务器
输入参数 无。
输出参数 成功或失败。
特别说明 Office公共
Open(FileName,
true
) 打开由FileName指定的文件
Save(FileName,
true
) 保存由FileName指定的文件
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报
。
打开APP,阅读全文并永久保存
查看更多类似文章
猜你喜欢
类似文章
【热】
打开小程序,算一算2024你的财运
在线编辑office文档(Weboffice)源码下载 源程序
WebOffice控件的使用----后台操作
(转)C# Office操作
ASP.NET使用点聚WebOffice实现文档在线浏览
web在线编辑word,excel,pdf插件
Excel 插件开发经验分享|Excel 插件开发经验分享 | 重庆诺怀软件有限公司 软件开发, app开发, 微信开发, 小程序开发
更多类似文章 >>
生活服务
热点新闻
留言交流
回顶部
联系我们
分享
收藏
点击这里,查看已保存的文章
导长图
关注
一键复制
下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!
联系客服
微信登录中...
请勿关闭此页面
先别划走!
送你5元优惠券,购买VIP限时立减!
5
元
优惠券
优惠券还有
10:00
过期
马上使用
×