How to determine if an Office Add-in is running under Excel or Excel Online?

前端 未结 4 617
一个人的身影
一个人的身影 2021-01-03 04:50

I\'m writing an Office Add-in (formerly, Apps for Office). I\'m using office.js and in some point of code I want to check if the app is running in excel (deskto

4条回答
  •  萌比男神i
    2021-01-03 05:07

    You can use document type:

    if (Microsoft.Office.WebExtension.context.document instanceof OSF.DDA.ExcelWebAppDocument) {
                                        //Your app running on the web
                                    }
    
    if (Microsoft.Office.WebExtension.context.document instanceof OSF.DDA.ExcelDocument) {
                                        //Your app running in excel
                                    }
    

提交回复
热议问题