如何确定Office加载项是否在Excel或Excel Online下运行? [英] How to determine if an Office Add-in is running under Excel or Excel Online?

查看:186
本文介绍了如何确定Office加载项是否在Excel或Excel Online下运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一个Office加载项(以前的Apps for Office)。我正在使用 office.js ,在某些代码点我想检查应用程序是运行在excel(桌面软件)还是在网络上运行(Excel Online)



如下所示:

  if(Office.IsRunningOnWeb){
//做某事
}


解决方案

您可以使用文档类型:

  if(Microsoft.Office.WebExtension.context.document instanceof OSF.DDA.ExcelWebAppDocument){
//您的应用程序在网络上运行
}

if(Microsoft.Office.WebExtension.context.document instanceof OSF.DDA.ExcelDocument){
//您的应用程序在excel $ b中运行$ b}


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 (desktop software) or running on the web (Excel Online)

Something like:

if (Office.IsRunningOnWeb){
    // Do something.
}

解决方案

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
                                }

这篇关于如何确定Office加载项是否在Excel或Excel Online下运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆