问题
I want to use Preview features of office-js Excel API (specifically DataValidation).
This page says that I should use Beta version of the library and they provide a link but I have no idea what to do with it.
What I did so far:
I have added the js path to index.html.
I copied types from ts file to file in node_modules.
But it doesn't seem like a good solution since whenever I update @types/office-js I would also have to copy source again...
回答1:
in order to use preview Api you only need:
- Install latest insiders fast build, AND
- refer to the BETA CDN for office.js and if you will use typescript the typescript library: here are the URLs you need to use, as Ricky suggests make sure you add those references to your HTML or JS files in your web app.
https://appsforoffice.microsoft.com/lib/beta/hosted/office.js https://appsforoffice.microsoft.com/lib/beta/hosted/office.d.ts
回答2:
If you are using angular follow these steps.
Refer to the beta office js cdn.
<script src="https://appsforoffice.microsoft.com/lib/beta/hosted/office.js" type="text/javascript"></script>
If you need type definition for beta version, install this.
npm install --save-dev @types/office-js-preview
If you were already using the production version, uninstall it:
npm uninstall --save-dev @types/office-js
Mention the following type in tsconfig.app.json like this (if types is already empty).
"types": ["office-js-preview"]
来源:https://stackoverflow.com/questions/51441910/how-to-use-preview-version-of-office-js-excel-api