I am looking to use office-js locally with angular 4 in an Excel Web based add-in. It will be installed and managed by npm. The calculator example shows that it is possible previously. Apps for Office: Enable offline apps.
I have installed office-js via npm install @microsoft/office-js --save
and can see the JavaScript files in node_modules.
The Microsoft npm example says you should use a <script src="node_modules\@microsoft\office-js\dist\office.js"></script>
but I am running into a few issues using Angular4:
node_modules paths should not be revealed. I saw some information about app.use and express but this does not work after I use
ng build --prod --aot
as it no longer references the correct place for its src.if I use a grunt to push the office-js folder directly into the dist folder then I can get the command to work in the header. The creates another problem where office.js injects a below itself tries to call another file from the office-js folder and uses an absolute path which includes the localhost. I would like that path to be relative to the office.js file but I have not figured that out yet.
I have read that you can write
import 'office-js;'
or use theimport {Office} from '@microsoft/office-js'
. I tried injecting this at the top of main.ts, index.ts and even index.js but it either said that office-js is not a module or said nothing and I was not able to get Excel to communicate with the html. Where should this go? How does it get linked to the header of index.html if you import it as a module? Are you meant to have the @types/office-js if you are using the @microsoft/office-js?
I am new to this and am looking for guidance. The aim is to have a Excel web addin that can perform offline as a standalone PWA (similar to the calculator).
I understand VSTO is an option, but we will probably look to expand to a web based service in the future once the initial ideas has been demonstrated to work with old tools. Stepping stones. Any thoughts?
The app will not be hosted on the store so I not concerned about the requirement to link to the CDN.