word, excel, ppt online preview function

When we are developing web projects, we always encounter the function of uploading attachments and previewing them online, especially when they are similar to the oa function.

 

Microsoft's official website itself provides an API for online preview

First convert the document to be previewed into .docx, .xlsx, .pptx format files.

Then you need to encode the URL of the previewed file path: http://tool.chinaz.com/Tools/URLEncode.aspx

以下是支持在线预览链接的示例
--ppt
http://view.officeapps.live.com/op/view.aspx?src=http%3a%2f%2fvideo.ch9.ms%2fbuild%2f2011%2fslides%2fTOOL-532T_Sutter.pptx
--excel
http://view.officeapps.live.com/op/view.aspx?src=http%3A%2F%2Flearn.bankofamerica.com%2Fcontent%2Fexcel%2FWedding_Budget_Planner_Spreadsheet.xlsx
--word
http://view.officeapps.live.com/op/view.aspx?src=newteach.pbworks.com%2Ff%2Fele%2Bnewsletter.docx

 

Oh, by the way, the most important thing is that the url after src must be a domain name, and then convert the url encoding.

Well, that's it, let's study the rest by yourself!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325698916&siteId=291194637