How to determine if Office add-in works in Excel or Excel on the web?

I am writing an Office add-in (formerly an Office application). I use office.js, and at some point in the code I want to check if the application works in excel (desktop software) or works on the Internet (Excel Online).

Sort of:

if (Office.IsRunningOnWeb){
    // Do something.
}
+4
source share
3 answers

You can use the type of document:

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
                                }
+2
source

@Mehrandvd, , (, -, , Excel Online Desktop)? API Office.js, , .

, API, ( - ) API, Office.context.requirements.isSetSupported(name, version). , . (, Office).

API, Excel , , API- , . , .

Re. , @Afshin - , , API, , , , ... Office ( Excel Word API, 2015 ., Excel Word OfficeExtension).

, !

~

    Office, MSFT

PS: , office-js ; stackoverflow, Office Extensibility Microsoft.

+4

, , . , . :

if (window.top == window) {
//the add-in is not running in Excel Online
}
else
{
//the add-in is running in Excel online
}
0

All Articles