Make a web requsted or post, to external URL for data - office-scripts

Is it possible to make web requests to an external url to grab data or post data to?
This way you can easily get data from external API's.

Here's the document to doing web requests in Office Scripts
https://learn.microsoft.com/en-us/office/dev/add-ins/excel/custom-functions-web-reqs?view=word-js-preview

Please note that there is JavaScript for Office Add-ins (https://learn.microsoft.com/en-us/office/dev/add-ins/?view=word-js-preview) and should be tagged #office-js.
This type of JavaScript can be used in different Office applications (web and desktop) to create add-ins that will work in both web apps and desktop applications.
This Office JavaScript API can be explored using Script Lab.
The tag #Office-Scripts reference Office Scripts for Excel on the web (https://learn.microsoft.com/en-us/office/dev/scripts/) which is also in preview and currently only available in Excel on the Web.
It can be enabled from the Admin portal of Microsoft365 (Formerly Office 365) under Settings/Settings and appears in Excel on the Web as a new tab called Automation.
It gives users the possibility to record macros and create scripts via the Office Scripts editor pane. Office-Scripts for Excel on the Web uses TypeScript. It is more limited in its scope than Office Add-in JavaScript.
So, to answer the question with regards to Office-Scripts for Excel on the Web, and as stated in the documentation, it is currently not possible to reference external API.
Read more here: https://learn.microsoft.com/en-us/office/dev/scripts/resources/add-ins-differences

Related

How do I distribute excel office add-in(w/ office.js) in privately?

Q1. Are there any method to distribute excel office add-in(w/ office.js) in privately?
(Will office.js add-in also be distributed like VSTO's .exe OR .xla/.xlam macro files with password?)
Q2. If I run office add-in server(node.js) on my on-premise server, What will have to be distributed to the end-users?
(I want to hide the core source logic unlike VBA macro.)
I am now developing an excel office add-in. But there seems to be some limitation to deploy to the end-users in my company.(We are now testing environment for pilot, and using office 365 but it is restricted by IT's policy)
When I refer to the official documentation below, the docs says that the way to deploy add-in in privately are Microsoft 365 admin center OR SharePoint catalog.(AppSource is publicly for everyone.)
refer. https://learn.microsoft.com/en-us/office/dev/add-ins/publish/publish
However, it seems that it have to use Microsoft's services or components like SharePoint or admin center. I don't want to use these items because I want to flexibly cope with various environments.
I have also read the article as below.
refer. How to distribute private office add-ins?
But the reply thread seems that the writer couldn't get the appropriate answer what I also want to know.
I want to know the other ways to distribute excel office add-in(w/ office.js) without unveiling my core source logic and what is the minimum materials I have to provide to the end-users(i.g. manifest or something).
Typically, as you have already know, you need to host the add-in's source code on the web server anywhere. The manifest file just refers to the place where the sources are stored. And the single file which should be provided to be able to side-load add-ins locally is the manifest file. Everything else is hosted under your control.
Due to the nature of the web technology you can't hide the source code from users. The add-in acts like a regular web page. The best what you could do is to obfuscate your code.

Excel Javascript API - Sharing

(Desktop version) I'm new to using the javascript API for excel, but is it possible to create an excel add-in and share with other users without having to add the add-in to an app source etc? Can it be embedded in the excel file etc. I'd like to share scripts with other users the same way that I can share VBA if it's possible?
for security reasons as well as to make manageability of your add-ins easier, we do not store the code within the workbook, like VBA. Instead, the javascript is hosted on your website and we have a reference to your add-in saved in the workbook.
What this means, is to get a similar experience to VBA, you must either have the add-in hosted on app source (which will make it accessible via the Office Store), OR each user in an organization must have the add-in deployed or available to them (here we recommend centralized deployment as it will give the most robust experience).
This has all the current deployment options you can use for Office add-ins: https://learn.microsoft.com/en-us/office/dev/add-ins/publish/publish
thanks!

Consume external API from within OfficeJS

I'm currently working on creating my first ever Office 365 plugin specifically for Excel. I would like this plugin to be able to make REST API calls to an external service(either a micro service or a Lambda). I haven't written the REST service yet but want to know if this is even remotely possible from within Office JS. I found a similar question asked Use Office.js APIs from outside an Office Add in back in 2016 when Office-JS was brand new. Just wanted to know if there is better support for REST API from within Office-JS and if so where can i find specific documentation to accomplish this.
Yes. You can do this. Any REST API that can be called in a web app can be called from an Excel Add-in because the add-in essentially a web app embedded in Excel. E.g., the same ajax request that would work in a web app would work in the add-in.
I think the question that you linked to is different. It seems to be about the Excel REST APIs which are not the same as the Office.js.

C# based excel-functions within Office.js javascript API possible?

I'm currently developing a tool using the Office javascript API. However, I would like to provide an own Excel function (something like =SUM(A1:A5)), which is based on code in C#.
Is there any way to avoid shipping two individual plug-ins from the users point of view? Can I combine both technologies to one plug-in?
If you are only targeting the desktop version of Excel then you can create a VSTO add-in instead of a JavaScript-based add-in. Within this adding you can include the code for your custom functions in the VSTO project and make sure they are correctly registered. One solution could be to create your own MSI-based installer, e.g. using Windows Installer XML (WIX) or Nullsoft's NSIS tool.
With this "classic" VSTO add-in technology you won't be able to target Excel on Mac, on mobile platforms or Excel Online in the browser though.
Yes there is also an alternative solution to creating a desktop C# add-in with VSTO or ExcelDNA as suggested by Dirk.
A javascript web add-in is just a web page with a library : office.js filling the gap between your logic and the office host application.
Why not passing the input to an API written in C# (this can be or not the same server serving the add-in) that will do the calculation ? The javascript will be there only to pass data and set the calculation results in spreadsheet.
I use ILMerge to combine my dlls. You can add it as a post build command so that they are merged on successful build.

Using Office Web Apps, Can you open a document via webdav?

We're in the process of converting a legacy desktop application into a web enabled equivalent.
However one feature is causing difficulty, editing MS Word documents.
Current proposed solution is publishing the DOC and DOCX files via WebDAV and using a custom ActiveX component to launch WinWord and pointing it at a file via a URL.
This works but it's limited in scope and the worlds moved on since it was conceived.
Is is possible to use the new Office Web Apps to do this completely in-browser?
So, still publish DOC files via WebDAV, but only to a web server hosting the Office Web Apps and redirecting the user to a URL rather than launching a local windows exe via activex.
Can you do this with the new Office Web Apps?
Where is the documentation on how to achieve this?
Yes, you can launch editing of MS Office documents from a web browser, using the sharepoint dll available in IE:
Eg
Set EditDocumentButton = CreateObject("SharePoint.OpenDocuments.3")
strDocument = 'http://localhost:8080' + strDocument;
EditDocumentButton.EditDocument(strDocument)
If your server is running java you can use Milton (http://milton.io) to integrate directly into your business app and edit the document in place.

Resources