Coder Social home page Coder Social logo

piyumi25 / office-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from officedev/office-js

0.0 1.0 0.0 26.91 MB

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.

Home Page: https://dev.office.com/reference/add-ins/javascript-api-for-office

License: Other

JavaScript 100.00%

office-js's Introduction

NPM Deployment Status

Office JavaScript APIs

The JavaScript API for Office enables you to create web applications that interact with the object models in Office host applications. Your application will reference the office.js library, which is a script loader. The office.js library loads the object models that are applicable to the Office application that is running the add-in.

The NPM package for Office.js is a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js. The NPM also offers alpha and beta versions for faster-cadence beta-testing (relative to the slower-cadence official BETA endpoint).


Installing

To install "office-js" locally via the NPM package, run

npm install @microsoft/office-js --save

Once installed, the Office.js script reference can be used as

<script src="node_modules\@microsoft\office-js\dist\office.js"></script>

IntelliSense definitions

TypeScript definitions for Office.js are available.

Visual Studio 2017+ can use these same TypeScript definitions, even for regular JavaScript. For JavaScript IntelliSense in earlier versions of Visual Studio, an office-vsdoc.js is available alongside the office.js file. As long as you have a Scripts/_references.js file in your VS project, and as long as you substitute the existing triple-slash reference (/// <reference path="https://.../office.js" />) with the new location (the -vsdoc part gets substituted automatically, so use it just as you would in a <script src=""> reference), you should have the corresponding JavaScript IntelliSense.


Accessing the NPM files via a CDN

In addition to downloading the files locally, you can also use them via an external service like https://unpkg.com, which provides best-effort (no uptime guarantees) CDN hosting for npm packages. This is especially useful for trying out alpha or beta builds. To do so, simply change the script reference to:

<script src="https://unpkg.com/@microsoft/office-js/dist/office.js"></script>

You can see the different versions of the NPM package listed in the dropdown on the top right at https://unpkg.com/@microsoft/office-js/. This provides the alpha and beta versions as well.

To view the latest version numbers for each of the tags, you can also run the following command on the command-line:

npm view @microsoft/office-js dist-tags --json

When you have a version number, can use it as follows with https://unpkg.com: (appending @<version-#> right after office-js; e.g., .../[email protected]/dist/...

<script src="https://unpkg.com/@microsoft/[email protected]/dist/office.js"></script>

Production vs. Beta vs. Private versions

Office.js versioning is described in detail in https://dev.office.com/docs/add-ins/develop/office-js-versioning. Importantly, there is a large difference between what is in the JS files, versus what are the capabilities of a particular computer (i.e., older or slower-to-update versions of office).

The NPM package and the repo branches assume the following structure.

GitHub branch name NPM tag name Description
release release (and also latest, a default NPM tag) The latest of the released publicly-available APIs.
This should be identical with what is currently on https://appsforoffice.microsoft.com/lib/1/hosted/office.js
beta beta Forthcoming APIs, not necessarily ready for public consumption yet (and may still change...), but likely available on Insider Fast (and maybe Insider Slow) builds.
This should be identical to what is currently on https://appsforoffice.microsoft.com/lib/beta/hosted/office.js
release-next release-next A forthcoming update the the "release" branch (typically a couple weeks ahead of "release")
beta-next beta-next A forthcoming update the the "beta" branch (typically a couple weeks ahead of "beta")
private private Any flavor of a release, but deployed for a very specific need (e.g., try out something experimental) or for a specific partner. Unlike the other tags, successive versions of this tag are not necessarily cumulative updates; it is possible to have a 1.1.2-private.1 that has the beta JS, and then a 1.1.2-private.2 that only contains the publicly-available release APIs (with maybe some tweaks)

Using a Private or Beta version with Script Lab

To use a version of the NPM package with Script Lab, substitute the CDN reference and the @types/office-js reference with the NPM package name and version. [Note: Script Lab uses https://unpkg.com for resolving the package names, so it's very similar guidance as above].

For example, to use a 1.1.2-beta-next.0 version, use the following references:

@microsoft/[email protected]/dist/office.js
@microsoft/[email protected]/dist/office.d.ts

Using the NPM package with Script Lab


More info

For more information on Office Add-ins and the Office JavaScript APIs, see:

office-js's People

Contributors

zlatkovsky avatar rick-kirkham avatar shaofengzhu avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.