office文档 在线预览 (doc、ppt、xls)

office 在线预览 
调用微软的api,将office文档转换为html,然后实现预览。

参考我们的实现方式:http://demo.kalcaddle.com/?user/loginSubmit&name=guest&password=guest
然后最后把得到的地址以iframe方式嵌入到网页即可实现预览
之后发一些,office在线编辑、保存的文章。


还有本地转换的方案,dsoframer。可参考:
http://view.gokuai.com/op/view.aspx?src=http%3A%2F%2Fdemo.kalcaddle.com%2Fdata%2FUser%2Fdemo%2Fhome%2Fdownload%2FC%2B%2B%E4%B8%AD%E5%86%85%E5%AD%98%E5%88%86%E9%85%8D%E5%8F%8A%E5%A0%86%E5%92%8C%E6%A0%88.docx

代码段:

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';
}

文章出自:http://www.oschina.net/code/snippet_127872_34706

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值