调用微软的api,将office文档转换为html,然后实现预览。然后最后把得到的地址以iframe方式嵌入到网页即可实现预览。参考我们的实现方式:http://demo.kalcaddle.com/?user/loginSubmit&name=guest&password=guest
之后发一些,office在线编辑、保存的文章。dsoframer类似都是可行的方案。
如果需要内网,国外访问慢或者害怕文件泄露,可以自信搭建一套。
需要在服务器上安装一套web office软件, 用来实现转换、输出、保存等功能。 可以以接口方式提供给第三方使用(其他语言、或服务)
效果可参考:http://url.cn/RtERE9
够快网盘用的是这种方案,不过正版服务器软件是需要付费的;还有就是只能搭建在windows
office365 这方面比较专业,可以参考:http://www.officeweb365.com/viewview.html
Office在线预览及PDF在线预览的实现方式大集合:http://www.officeweb365.com/officetoview.html
代码片段(1)[全屏查看所有代码]
1. [代码][JavaScript]代码
var
openOffice =
function
(url,ext){
var
app_url,temp_url;
switch
(ext) {
case
'doc'
:
case
'docx'
:
case
'docm'
:
case
'dot'
:
app_url =
'http://sg1b-word-view.officeapps.live.com/wv/wordviewerframe.aspx?ui=zh-CN&rs=zh-CN&WOPISrc='
;
break
;
case
'ppt'
:
case
'pptm'
:
case
'pptx'
:
app_url =
'http://sg1b-powerpoint.officeapps.live.com/p/PowerPointFrame.aspx?PowerPointView=ReadingView&ui=zh-CN&rs=zh-CN&WOPISrc='
;
break
;
case
'xls'
:
case
'xlsb'
:
case
'xlsm'
:
case
'xlsx'
:
app_url =
'http://sg1b-excel.officeapps.live.com/x/_layouts/xlviewerinternal.aspx?ui=zh-CN&rs=zh-CN&WOPISrc='
;
break
;
default
:
break
;
}
temp_url =
'http://sg1b-15-view-wopi.wopi.live.net:808/oh/wopi/files/@/wFileId?wFileId='
;
temp_url += encodeURIComponent(url);
return
app_url+encodeURIComponent(temp_url)+
'&access_token=1&access_token_ttl=0'
;
}